refactor(nix-compat): Move serialization machinery into wire.
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>
This commit is contained in:
parent
11ee751aff
commit
8df919dcf0
28 changed files with 45 additions and 49 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -1,7 +1 @@
|
|||
pub mod worker_protocol;
|
||||
|
||||
mod protocol_version;
|
||||
pub use protocol_version::ProtocolVersion;
|
||||
|
||||
pub mod de;
|
||||
pub mod ser;
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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"))]
|
||||
|
|
@ -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"))]
|
||||
|
|
@ -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"))]
|
||||
|
|
@ -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};
|
||||
|
||||
|
|
@ -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() {
|
||||
|
|
@ -3,3 +3,9 @@
|
|||
|
||||
mod bytes;
|
||||
pub use bytes::*;
|
||||
|
||||
mod protocol_version;
|
||||
pub use protocol_version::ProtocolVersion;
|
||||
|
||||
pub mod de;
|
||||
pub mod ser;
|
||||
|
|
|
|||
|
|
@ -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"))]
|
||||
|
|
@ -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"))]
|
||||
|
|
@ -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"))]
|
||||
|
|
@ -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};
|
||||
|
||||
|
|
@ -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;
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue