diff --git a/rosenpass/src/api/boilerplate/request_ref.rs b/rosenpass/src/api/boilerplate/request_ref.rs index 2b2e1930..12f83b28 100644 --- a/rosenpass/src/api/boilerplate/request_ref.rs +++ b/rosenpass/src/api/boilerplate/request_ref.rs @@ -20,7 +20,7 @@ impl RequestRef { /// # Examples /// /// ``` - /// use zerocopy::AsBytes; + /// use zerocopy::IntoBytes; /// /// use rosenpass::api::{PingRequest, RequestRef, RequestMsgType}; /// diff --git a/rosenpass/src/api/boilerplate/response_ref.rs b/rosenpass/src/api/boilerplate/response_ref.rs index 1f8b7dad..50b36142 100644 --- a/rosenpass/src/api/boilerplate/response_ref.rs +++ b/rosenpass/src/api/boilerplate/response_ref.rs @@ -23,7 +23,7 @@ impl ResponseRef { /// # Examples /// /// ``` - /// use zerocopy::AsBytes; + /// use zerocopy::IntoBytes; /// /// use rosenpass::api::{PingResponse, ResponseRef, ResponseMsgType}; /// // Produce the original PingResponse diff --git a/rosenpass/src/msgs.rs b/rosenpass/src/msgs.rs index 21b1c363..7f05ca28 100644 --- a/rosenpass/src/msgs.rs +++ b/rosenpass/src/msgs.rs @@ -51,7 +51,7 @@ pub type MsgEnvelopeCookie = [u8; COOKIE_SIZE]; /// /// ``` /// use rosenpass::msgs::{Envelope, InitHello}; -/// use zerocopy::{IntoBytes, FromBytes, Ref}; +/// use zerocopy::{FromZeros, IntoBytes, FromBytes, Ref}; /// use memoffset::offset_of; /// /// // Zero-initialization @@ -106,7 +106,7 @@ pub struct Envelope { /// /// ``` /// use rosenpass::msgs::{Envelope, InitHello}; -/// use zerocopy::{IntoBytes, FromBytes, Ref}; +/// use zerocopy::{FromZeros, IntoBytes, FromBytes, Ref}; /// use memoffset::span_of; /// /// // Zero initialization @@ -155,7 +155,7 @@ pub struct InitHello { /// /// ``` /// use rosenpass::msgs::{Envelope, RespHello}; -/// use zerocopy::{IntoBytes, FromBytes, Ref}; +/// use zerocopy::{FromZeros, IntoBytes, FromBytes, Ref}; /// use memoffset::span_of; /// /// // Zero initialization @@ -206,7 +206,7 @@ pub struct RespHello { /// /// ``` /// use rosenpass::msgs::{Envelope, InitConf}; -/// use zerocopy::{IntoBytes, FromBytes, Ref}; +/// use zerocopy::{IntoBytes, FromBytes, FromZeros, Ref}; /// use memoffset::span_of; /// /// // Zero initialization @@ -264,7 +264,7 @@ pub struct InitConf { /// /// ``` /// use rosenpass::msgs::{Envelope, EmptyData}; -/// use zerocopy::{IntoBytes, FromBytes, Ref}; +/// use zerocopy::{FromZeros, IntoBytes, FromBytes, Ref}; /// use memoffset::span_of; /// /// // Zero initialization diff --git a/rosenpass/src/protocol/protocol.rs b/rosenpass/src/protocol/protocol.rs index 0994000b..43ca38f8 100644 --- a/rosenpass/src/protocol/protocol.rs +++ b/rosenpass/src/protocol/protocol.rs @@ -464,7 +464,7 @@ pub type KnownResponseHash = Public<16>; /// # Examples /// /// ``` -/// use zerocopy::FromZeroes; +/// use zerocopy::FromZeros; /// use rosenpass::protocol::KnownResponseHasher; /// use rosenpass::msgs::{Envelope, InitConf}; /// diff --git a/rosenpass/src/protocol/test.rs b/rosenpass/src/protocol/test.rs index b5f58823..4d93e846 100644 --- a/rosenpass/src/protocol/test.rs +++ b/rosenpass/src/protocol/test.rs @@ -2,7 +2,7 @@ use std::{borrow::BorrowMut, fmt::Display, net::SocketAddrV4, ops::DerefMut}; use anyhow::{Context, Result}; use serial_test::serial; -use zerocopy::{AsBytes, FromBytes, FromZeroes}; +use zerocopy::{FromBytes, FromZeros, Immutable, IntoBytes, KnownLayout}; use rosenpass_cipher_traits::primitives::Kem; use rosenpass_ciphers::StaticKem; @@ -538,10 +538,10 @@ fn init_conf_retransmission(protocol_version: ProtocolVersion) -> anyhow::Result srv.initiate_handshake(peer, buf.as_mut_slice())? .discard_result(); let msg = truncating_cast_into::>(buf.borrow_mut())?; - Ok(msg.read()) + Ok(zerocopy::Ref::read(&msg)) } - fn proc_msg( + fn proc_msg( srv: &mut CryptoServer, rx: &Envelope, ) -> anyhow::Result> { @@ -551,7 +551,7 @@ fn init_conf_retransmission(protocol_version: ProtocolVersion) -> anyhow::Result .context("Failed to produce RespHello message")? .discard_result(); let msg = truncating_cast_into::>(buf.borrow_mut())?; - Ok(msg.read()) + Ok(zerocopy::Ref::read(&msg)) } fn proc_init_hello( @@ -582,17 +582,21 @@ fn init_conf_retransmission(protocol_version: ProtocolVersion) -> anyhow::Result } // TODO: Implement Clone on our message types - fn clone_msg(msg: &Msg) -> anyhow::Result { - Ok(truncating_cast_into_nomut::(msg.as_bytes())?.read()) + fn clone_msg( + msg: &Msg, + ) -> anyhow::Result { + Ok(zerocopy::Ref::read(&truncating_cast_into_nomut::( + msg.as_bytes(), + )?)) } - fn break_payload( + fn break_payload( srv: &mut CryptoServer, peer: PeerPtr, msg: &Envelope, ) -> anyhow::Result> { let mut msg = clone_msg(msg)?; - msg.as_bytes_mut()[memoffset::offset_of!(Envelope, payload)] ^= 0x01; + msg.as_mut_bytes()[memoffset::offset_of!(Envelope, payload)] ^= 0x01; msg.seal(peer, srv)?; // Recalculate seal; we do not want to focus on "seal broken" errs Ok(msg) } diff --git a/rosenpass/tests/api-integration-tests-api-setup.rs b/rosenpass/tests/api-integration-tests-api-setup.rs index 54ae051d..e35d8088 100644 --- a/rosenpass/tests/api-integration-tests-api-setup.rs +++ b/rosenpass/tests/api-integration-tests-api-setup.rs @@ -27,7 +27,7 @@ use rosenpass_util::{ }; use std::os::fd::{AsFd, AsRawFd}; use tempfile::TempDir; -use zerocopy::AsBytes; +use zerocopy::IntoBytes; struct KillChild(std::process::Child); diff --git a/rosenpass/tests/api-integration-tests.rs b/rosenpass/tests/api-integration-tests.rs index ef54d281..241cefc0 100644 --- a/rosenpass/tests/api-integration-tests.rs +++ b/rosenpass/tests/api-integration-tests.rs @@ -14,7 +14,7 @@ use rosenpass_util::{ }; use rosenpass_util::{mem::DiscardResultExt, zerocopy::ZerocopySliceExt}; use tempfile::TempDir; -use zerocopy::AsBytes; +use zerocopy::IntoBytes; use rosenpass::config::ProtocolVersion; use rosenpass::protocol::basic_types::SymKey; diff --git a/util/tests/janitor.rs b/util/tests/janitor.rs index 06612036..2eefcafa 100644 --- a/util/tests/janitor.rs +++ b/util/tests/janitor.rs @@ -47,7 +47,7 @@ async fn janitor_demo() -> anyhow::Result<()> { anyhow::Ok(()) }) } - .await; + .await?; // At this point, all background jobs have finished, now we can check the result of all our // additions