about summary refs log tree commit diff
path: root/tvix/nix-compat
diff options
context:
space:
mode:
authorFlorian Klink <flokli@flokli.de>2024-04-07T21·52+0300
committerclbot <clbot@tvl.fyi>2024-04-08T07·02+0000
commitfd749070e29bd3856e5923136ea97260d933e3db (patch)
tree7207bb9576ec9ac872439444a04cb4de8be93af2 /tvix/nix-compat
parent71a3855f0990cbdadfa5ff109db62912e5f3e320 (diff)
refactor(tvix/nix-compat/wire): move magic bytes to worker_protocol r/7874
`primitive.rs` implements reading and writing primitive (fixed-length)
types in the wire format, used in the the nix daemon protocol and NAR
format.

Move worker-protocol specific magic bytes to worker_protocol.rs (and
possibly further split there once needed)

Change-Id: If681c01e9460294619f1d000229b81f0ac745810
Reviewed-on: https://cl.tvl.fyi/c/depot/+/11377
Autosubmit: flokli <flokli@flokli.de>
Tested-by: BuildkiteCI
Reviewed-by: picnoir picnoir <picnoir@alternativebit.fr>
Diffstat (limited to 'tvix/nix-compat')
-rw-r--r--tvix/nix-compat/src/wire/primitive.rs7
-rw-r--r--tvix/nix-compat/src/wire/worker_protocol.rs7
2 files changed, 7 insertions, 7 deletions
diff --git a/tvix/nix-compat/src/wire/primitive.rs b/tvix/nix-compat/src/wire/primitive.rs
index 119053b89d87..ee0f5fc4279d 100644
--- a/tvix/nix-compat/src/wire/primitive.rs
+++ b/tvix/nix-compat/src/wire/primitive.rs
@@ -4,13 +4,6 @@
 
 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";
-// LE-encoded protocol version.
-pub static PROTOCOL_VERSION: [u8; 8] = [0x23, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00];
-
 #[allow(dead_code)]
 /// Read a u64 from the AsyncRead (little endian).
 pub async fn read_u64<R: AsyncReadExt + Unpin>(r: &mut R) -> std::io::Result<u64> {
diff --git a/tvix/nix-compat/src/wire/worker_protocol.rs b/tvix/nix-compat/src/wire/worker_protocol.rs
index 77d510425016..c9d055319273 100644
--- a/tvix/nix-compat/src/wire/worker_protocol.rs
+++ b/tvix/nix-compat/src/wire/worker_protocol.rs
@@ -11,6 +11,13 @@ use crate::wire::primitive;
 
 use super::bytes::read_string;
 
+// 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";
+// LE-encoded protocol version.
+pub static PROTOCOL_VERSION: [u8; 8] = [0x23, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00];
+
 pub static STDERR_LAST: u64 = 0x616c7473;
 
 /// Max length of a Nix setting name/value. In bytes.