feat(tvix/nix-compat): introduce magic hello/response

Setting the wire module as public to re-use it from tvix-daemon.

Change-Id: I570cffc480c7b784d813663f77572bbe9d4e8259
Reviewed-on: https://cl.tvl.fyi/c/depot/+/11197
Tested-by: BuildkiteCI
Reviewed-by: flokli <flokli@flokli.de>
This commit is contained in:
Picnoir 2024-03-19 14:34:53 +01:00 committed by picnoir picnoir
parent bbb3d4cc40
commit 09e5f1782c
2 changed files with 6 additions and 1 deletions

View file

@ -5,4 +5,4 @@ pub mod narinfo;
pub mod nixbase32; pub mod nixbase32;
pub mod nixhash; pub mod nixhash;
pub mod store_path; pub mod store_path;
mod wire; pub mod wire;

View file

@ -4,6 +4,11 @@
use tokio::io::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt}; use tokio::io::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt};
// LE-encoded nixc on 64 bits. Because why not.
pub static MAGIC_HELLO: [u8; 8] = *b"cxin\0\0\0\0";
// LE-encoded dxio on 64 bits. What's dxio? I have no clue.
pub static MAGIC_HELLO_RESPONSE: [u8; 8] = *b"oixd\0\0\0\0";
#[allow(dead_code)] #[allow(dead_code)]
/// Read a u64 from the AsyncRead (little endian). /// Read a u64 from the AsyncRead (little endian).
pub async fn read_u64<R: AsyncReadExt + Unpin>(r: &mut R) -> std::io::Result<u64> { pub async fn read_u64<R: AsyncReadExt + Unpin>(r: &mut R) -> std::io::Result<u64> {