diff options
author | Vova Kryachko <v.kryachko@gmail.com> | 2024-11-10T16·16-0500 |
---|---|---|
committer | Vladimir Kryachko <v.kryachko@gmail.com> | 2024-11-10T20·54+0000 |
commit | 8df919dcf04b5c2502f3a63b4d013669da5e70c1 (patch) | |
tree | 3a527553fc48f62f331ef2b6a5667b6fe591290d /tvix/nix-compat | |
parent | 11ee751aff42804319788a9033685a455bdf8f8e (diff) |
refactor(nix-compat): Move serialization machinery into wire. r/8898
This groups most `wire` feature gated logic into a single module. The nix_daemon module will be gated by a feature that adds nix-compat-derive as a dependency. All of this is a way to break the crate2nix dependency cycle between nix-compat and nix-compat-derive(which depends on nix-compat for its doctests). Change-Id: I95938a6f280c11967371ff21f8b5a19e6d3d3805 Reviewed-on: https://cl.tvl.fyi/c/depot/+/12761 Tested-by: BuildkiteCI Reviewed-by: flokli <flokli@flokli.de>
Diffstat (limited to 'tvix/nix-compat')
-rw-r--r-- | tvix/nix-compat/src/lib.rs | 2 | ||||
-rw-r--r-- | tvix/nix-compat/src/nix_daemon/mod.rs | 6 | ||||
-rw-r--r-- | tvix/nix-compat/src/nix_daemon/worker_protocol.rs | 2 | ||||
-rw-r--r-- | tvix/nix-compat/src/wire/de/bytes.rs (renamed from tvix/nix-compat/src/nix_daemon/de/bytes.rs) | 2 | ||||
-rw-r--r-- | tvix/nix-compat/src/wire/de/collections.rs (renamed from tvix/nix-compat/src/nix_daemon/de/collections.rs) | 2 | ||||
-rw-r--r-- | tvix/nix-compat/src/wire/de/int.rs (renamed from tvix/nix-compat/src/nix_daemon/de/int.rs) | 2 | ||||
-rw-r--r-- | tvix/nix-compat/src/wire/de/mock.rs (renamed from tvix/nix-compat/src/nix_daemon/de/mock.rs) | 4 | ||||
-rw-r--r-- | tvix/nix-compat/src/wire/de/mod.rs (renamed from tvix/nix-compat/src/nix_daemon/de/mod.rs) | 0 | ||||
-rw-r--r-- | tvix/nix-compat/src/wire/de/reader.rs (renamed from tvix/nix-compat/src/nix_daemon/de/reader.rs) | 5 | ||||
-rw-r--r-- | tvix/nix-compat/src/wire/mod.rs | 6 | ||||
-rw-r--r-- | tvix/nix-compat/src/wire/protocol_version.rs (renamed from tvix/nix-compat/src/nix_daemon/protocol_version.rs) | 0 | ||||
-rw-r--r-- | tvix/nix-compat/src/wire/ser/bytes.rs (renamed from tvix/nix-compat/src/nix_daemon/ser/bytes.rs) | 2 | ||||
-rw-r--r-- | tvix/nix-compat/src/wire/ser/collections.rs (renamed from tvix/nix-compat/src/nix_daemon/ser/collections.rs) | 2 | ||||
-rw-r--r-- | tvix/nix-compat/src/wire/ser/display.rs (renamed from tvix/nix-compat/src/nix_daemon/ser/display.rs) | 0 | ||||
-rw-r--r-- | tvix/nix-compat/src/wire/ser/int.rs (renamed from tvix/nix-compat/src/nix_daemon/ser/int.rs) | 2 | ||||
-rw-r--r-- | tvix/nix-compat/src/wire/ser/mock.rs (renamed from tvix/nix-compat/src/nix_daemon/ser/mock.rs) | 12 | ||||
-rw-r--r-- | tvix/nix-compat/src/wire/ser/mod.rs (renamed from tvix/nix-compat/src/nix_daemon/ser/mod.rs) | 0 | ||||
-rw-r--r-- | tvix/nix-compat/src/wire/ser/writer.rs (renamed from tvix/nix-compat/src/nix_daemon/ser/writer.rs) | 6 |
18 files changed, 25 insertions, 30 deletions
diff --git a/tvix/nix-compat/src/lib.rs b/tvix/nix-compat/src/lib.rs index f30c557889a8..ae9f1674468e 100644 --- a/tvix/nix-compat/src/lib.rs +++ b/tvix/nix-compat/src/lib.rs @@ -18,5 +18,3 @@ pub mod wire; pub mod nix_daemon; #[cfg(feature = "wire")] pub use nix_daemon::worker_protocol; -#[cfg(feature = "wire")] -pub use nix_daemon::ProtocolVersion; diff --git a/tvix/nix-compat/src/nix_daemon/mod.rs b/tvix/nix-compat/src/nix_daemon/mod.rs index a943b279f891..633fdbebd47c 100644 --- a/tvix/nix-compat/src/nix_daemon/mod.rs +++ b/tvix/nix-compat/src/nix_daemon/mod.rs @@ -1,7 +1 @@ pub mod worker_protocol; - -mod protocol_version; -pub use protocol_version::ProtocolVersion; - -pub mod de; -pub mod ser; diff --git a/tvix/nix-compat/src/nix_daemon/worker_protocol.rs b/tvix/nix-compat/src/nix_daemon/worker_protocol.rs index cc99bdb54fab..92259a0633a0 100644 --- a/tvix/nix-compat/src/nix_daemon/worker_protocol.rs +++ b/tvix/nix-compat/src/nix_daemon/worker_protocol.rs @@ -10,7 +10,7 @@ use tokio::io::{AsyncReadExt, AsyncWriteExt}; use crate::wire; -use super::ProtocolVersion; +use crate::wire::ProtocolVersion; static WORKER_MAGIC_1: u64 = 0x6e697863; // "nixc" static WORKER_MAGIC_2: u64 = 0x6478696f; // "dxio" diff --git a/tvix/nix-compat/src/nix_daemon/de/bytes.rs b/tvix/nix-compat/src/wire/de/bytes.rs index 7daced54eef7..4c64247f7051 100644 --- a/tvix/nix-compat/src/nix_daemon/de/bytes.rs +++ b/tvix/nix-compat/src/wire/de/bytes.rs @@ -34,7 +34,7 @@ mod test { use rstest::rstest; use tokio_test::io::Builder; - use crate::nix_daemon::de::{NixRead, NixReader}; + use crate::wire::de::{NixRead, NixReader}; #[rstest] #[case::empty("", &hex!("0000 0000 0000 0000"))] diff --git a/tvix/nix-compat/src/nix_daemon/de/collections.rs b/tvix/nix-compat/src/wire/de/collections.rs index cf79f584506a..e1271635e4e6 100644 --- a/tvix/nix-compat/src/nix_daemon/de/collections.rs +++ b/tvix/nix-compat/src/wire/de/collections.rs @@ -64,7 +64,7 @@ mod test { use rstest::rstest; use tokio_test::io::Builder; - use crate::nix_daemon::de::{NixDeserialize, NixRead, NixReader}; + use crate::wire::de::{NixDeserialize, NixRead, NixReader}; #[rstest] #[case::empty(vec![], &hex!("0000 0000 0000 0000"))] diff --git a/tvix/nix-compat/src/nix_daemon/de/int.rs b/tvix/nix-compat/src/wire/de/int.rs index eecf641cfe99..d505de9b1b24 100644 --- a/tvix/nix-compat/src/nix_daemon/de/int.rs +++ b/tvix/nix-compat/src/wire/de/int.rs @@ -45,7 +45,7 @@ mod test { use rstest::rstest; use tokio_test::io::Builder; - use crate::nix_daemon::de::{NixRead, NixReader}; + use crate::wire::de::{NixRead, NixReader}; #[rstest] #[case::simple_false(false, &hex!("0000 0000 0000 0000"))] diff --git a/tvix/nix-compat/src/nix_daemon/de/mock.rs b/tvix/nix-compat/src/wire/de/mock.rs index 31cc3a4897ba..8a1fb817743c 100644 --- a/tvix/nix-compat/src/nix_daemon/de/mock.rs +++ b/tvix/nix-compat/src/wire/de/mock.rs @@ -6,7 +6,7 @@ use std::thread; use bytes::Bytes; use thiserror::Error; -use crate::nix_daemon::ProtocolVersion; +use crate::wire::ProtocolVersion; use super::NixRead; @@ -189,7 +189,7 @@ mod test { use bytes::Bytes; use hex_literal::hex; - use crate::nix_daemon::de::NixRead; + use crate::wire::de::NixRead; use super::{Builder, Error}; diff --git a/tvix/nix-compat/src/nix_daemon/de/mod.rs b/tvix/nix-compat/src/wire/de/mod.rs index f85ccd8fea0e..f85ccd8fea0e 100644 --- a/tvix/nix-compat/src/nix_daemon/de/mod.rs +++ b/tvix/nix-compat/src/wire/de/mod.rs diff --git a/tvix/nix-compat/src/nix_daemon/de/reader.rs b/tvix/nix-compat/src/wire/de/reader.rs index 87c623b2220c..b7825f393c4e 100644 --- a/tvix/nix-compat/src/nix_daemon/de/reader.rs +++ b/tvix/nix-compat/src/wire/de/reader.rs @@ -8,8 +8,7 @@ use bytes::{Buf, BufMut, Bytes, BytesMut}; use pin_project_lite::pin_project; use tokio::io::{AsyncBufRead, AsyncRead, AsyncReadExt, ReadBuf}; -use crate::nix_daemon::ProtocolVersion; -use crate::wire::EMPTY_BYTES; +use crate::wire::{ProtocolVersion, EMPTY_BYTES}; use super::{Error, NixRead}; @@ -270,7 +269,7 @@ mod test { use tokio_test::io::Builder; use super::*; - use crate::nix_daemon::de::NixRead; + use crate::wire::de::NixRead; #[tokio::test] async fn test_read_u64() { diff --git a/tvix/nix-compat/src/wire/mod.rs b/tvix/nix-compat/src/wire/mod.rs index a197e3a1f451..c3e88dda05ec 100644 --- a/tvix/nix-compat/src/wire/mod.rs +++ b/tvix/nix-compat/src/wire/mod.rs @@ -3,3 +3,9 @@ mod bytes; pub use bytes::*; + +mod protocol_version; +pub use protocol_version::ProtocolVersion; + +pub mod de; +pub mod ser; diff --git a/tvix/nix-compat/src/nix_daemon/protocol_version.rs b/tvix/nix-compat/src/wire/protocol_version.rs index 19da28d484dd..19da28d484dd 100644 --- a/tvix/nix-compat/src/nix_daemon/protocol_version.rs +++ b/tvix/nix-compat/src/wire/protocol_version.rs diff --git a/tvix/nix-compat/src/nix_daemon/ser/bytes.rs b/tvix/nix-compat/src/wire/ser/bytes.rs index 19494934ff32..4338d3f8761e 100644 --- a/tvix/nix-compat/src/nix_daemon/ser/bytes.rs +++ b/tvix/nix-compat/src/wire/ser/bytes.rs @@ -45,7 +45,7 @@ mod test { use tokio::io::AsyncWriteExt as _; use tokio_test::io::Builder; - use crate::nix_daemon::ser::{NixWrite, NixWriter}; + use crate::wire::ser::{NixWrite, NixWriter}; #[rstest] #[case::empty("", &hex!("0000 0000 0000 0000"))] diff --git a/tvix/nix-compat/src/nix_daemon/ser/collections.rs b/tvix/nix-compat/src/wire/ser/collections.rs index 70c32e1c79ac..478e1d04d809 100644 --- a/tvix/nix-compat/src/nix_daemon/ser/collections.rs +++ b/tvix/nix-compat/src/wire/ser/collections.rs @@ -53,7 +53,7 @@ mod test { use tokio::io::AsyncWriteExt as _; use tokio_test::io::Builder; - use crate::nix_daemon::ser::{NixSerialize, NixWrite, NixWriter}; + use crate::wire::ser::{NixSerialize, NixWrite, NixWriter}; #[rstest] #[case::empty(vec![], &hex!("0000 0000 0000 0000"))] diff --git a/tvix/nix-compat/src/nix_daemon/ser/display.rs b/tvix/nix-compat/src/wire/ser/display.rs index a3438d50d8ff..a3438d50d8ff 100644 --- a/tvix/nix-compat/src/nix_daemon/ser/display.rs +++ b/tvix/nix-compat/src/wire/ser/display.rs diff --git a/tvix/nix-compat/src/nix_daemon/ser/int.rs b/tvix/nix-compat/src/wire/ser/int.rs index 1be06442e322..e68179c71dc7 100644 --- a/tvix/nix-compat/src/nix_daemon/ser/int.rs +++ b/tvix/nix-compat/src/wire/ser/int.rs @@ -67,7 +67,7 @@ mod test { use tokio::io::AsyncWriteExt as _; use tokio_test::io::Builder; - use crate::nix_daemon::ser::{NixWrite, NixWriter}; + use crate::wire::ser::{NixWrite, NixWriter}; #[rstest] #[case::simple_false(false, &hex!("0000 0000 0000 0000"))] diff --git a/tvix/nix-compat/src/nix_daemon/ser/mock.rs b/tvix/nix-compat/src/wire/ser/mock.rs index 1319a8da3228..7104a94238ff 100644 --- a/tvix/nix-compat/src/nix_daemon/ser/mock.rs +++ b/tvix/nix-compat/src/wire/ser/mock.rs @@ -7,7 +7,7 @@ use std::thread; use ::proptest::prelude::TestCaseError; use thiserror::Error; -use crate::nix_daemon::ProtocolVersion; +use crate::wire::ProtocolVersion; use super::NixWrite; @@ -491,11 +491,11 @@ mod test { use proptest::prelude::TestCaseError; use proptest::proptest; - use crate::nix_daemon::ser::mock::proptest::arb_extra_write; - use crate::nix_daemon::ser::mock::Operation; - use crate::nix_daemon::ser::mock::OperationType; - use crate::nix_daemon::ser::Error as _; - use crate::nix_daemon::ser::NixWrite; + use crate::wire::ser::mock::proptest::arb_extra_write; + use crate::wire::ser::mock::Operation; + use crate::wire::ser::mock::OperationType; + use crate::wire::ser::Error as _; + use crate::wire::ser::NixWrite; use super::{Builder, Error}; diff --git a/tvix/nix-compat/src/nix_daemon/ser/mod.rs b/tvix/nix-compat/src/wire/ser/mod.rs index 5860226f39eb..5860226f39eb 100644 --- a/tvix/nix-compat/src/nix_daemon/ser/mod.rs +++ b/tvix/nix-compat/src/wire/ser/mod.rs diff --git a/tvix/nix-compat/src/nix_daemon/ser/writer.rs b/tvix/nix-compat/src/wire/ser/writer.rs index 87e30580af34..da1c2b18c5e2 100644 --- a/tvix/nix-compat/src/nix_daemon/ser/writer.rs +++ b/tvix/nix-compat/src/wire/ser/writer.rs @@ -8,9 +8,7 @@ use bytes::{Buf, BufMut, BytesMut}; use pin_project_lite::pin_project; use tokio::io::{AsyncWrite, AsyncWriteExt}; -use crate::nix_daemon::ProtocolVersion; -use crate::wire::padding_len; -use crate::wire::EMPTY_BYTES; +use crate::wire::{padding_len, ProtocolVersion, EMPTY_BYTES}; use super::{Error, NixWrite}; @@ -225,7 +223,7 @@ mod test { use tokio::io::AsyncWriteExt as _; use tokio_test::io::Builder; - use crate::nix_daemon::ser::NixWrite; + use crate::wire::ser::NixWrite; use super::NixWriter; |