1616//! this module - [`U16`], [`I16`], [`U32`], [`F64`], etc. Unlike their native
1717//! counterparts, these types have alignment 1, and take a type parameter
1818//! specifying the byte order in which the bytes are stored in memory. Each type
19- //! implements the [`FromBytes`], [`AsBytes `], and [`Unaligned`] traits.
19+ //! implements the [`FromBytes`], [`IntoBytes `], and [`Unaligned`] traits.
2020//!
2121//! These two properties, taken together, make these types useful for defining
2222//! data structures whose memory layout matches a wire format such as that of a
3535//!
3636//! ```rust,edition2021
3737//! # #[cfg(feature = "derive")] { // This example uses derives, and won't compile without them
38- //! use zerocopy::{AsBytes , ByteSlice, FromBytes, FromZeroes , Ref, Unaligned};
38+ //! use zerocopy::{IntoBytes , ByteSlice, FromBytes, FromZeros, NoCell , Ref, Unaligned};
3939//! use zerocopy::byteorder::network_endian::U16;
4040//!
41- //! #[derive(FromZeroes , FromBytes, AsBytes , Unaligned)]
41+ //! #[derive(FromZeros , FromBytes, IntoBytes, NoCell , Unaligned)]
4242//! #[repr(C)]
4343//! struct UdpHeader {
4444//! src_port: U16,
@@ -346,18 +346,18 @@ order to uphold the invariants that a) the layout of `", stringify!($name), "`
346346has endianness `O` and that, b) the layout of `" , stringify!( $native) , "` has
347347the platform's native endianness.
348348
349- `" , stringify!( $name) , "` implements [`FromBytes`], [`AsBytes `], and [`Unaligned`],
349+ `" , stringify!( $name) , "` implements [`FromBytes`], [`IntoBytes `], and [`Unaligned`],
350350making it useful for parsing and serialization. See the module documentation for an
351351example of how it can be used for parsing UDP packets.
352352
353353[`new`]: crate::byteorder::" , stringify!( $name) , "::new
354354[`get`]: crate::byteorder::" , stringify!( $name) , "::get
355355[`set`]: crate::byteorder::" , stringify!( $name) , "::set
356356[`FromBytes`]: crate::FromBytes
357- [`AsBytes `]: crate::AsBytes
357+ [`IntoBytes `]: crate::IntoBytes
358358[`Unaligned`]: crate::Unaligned" ) ,
359359 #[ derive( Copy , Clone , Eq , PartialEq , Hash ) ]
360- #[ cfg_attr( any( feature = "derive" , test) , derive( KnownLayout , FromZeroes , FromBytes , AsBytes , Unaligned ) ) ]
360+ #[ cfg_attr( any( feature = "derive" , test) , derive( KnownLayout , NoCell , FromZeros , FromBytes , IntoBytes , Unaligned ) ) ]
361361 #[ repr( transparent) ]
362362 pub struct $name<O >( [ u8 ; $bytes] , PhantomData <O >) ;
363363 }
@@ -369,10 +369,12 @@ example of how it can be used for parsing UDP packets.
369369 /// SAFETY:
370370 /// `$name<O>` is `repr(transparent)`, and so it has the same layout
371371 /// as its only non-zero field, which is a `u8` array. `u8` arrays
372- /// are `FromZeroes`, `FromBytes`, `AsBytes`, and `Unaligned`.
373- impl_or_verify!( O => FromZeroes for $name<O >) ;
372+ /// are `NoCell`, `FromZeros`, `FromBytes`, `IntoBytes`, and
373+ /// `Unaligned`.
374+ impl_or_verify!( O => NoCell for $name<O >) ;
375+ impl_or_verify!( O => FromZeros for $name<O >) ;
374376 impl_or_verify!( O => FromBytes for $name<O >) ;
375- impl_or_verify!( O => AsBytes for $name<O >) ;
377+ impl_or_verify!( O => IntoBytes for $name<O >) ;
376378 impl_or_verify!( O => Unaligned for $name<O >) ;
377379 }
378380
@@ -813,7 +815,7 @@ module!(native_endian, NativeEndian, "native-endian");
813815mod tests {
814816 use {
815817 super :: * ,
816- crate :: { AsBytes , FromBytes , Unaligned } ,
818+ crate :: { FromBytes , IntoBytes , Unaligned } ,
817819 } ;
818820
819821 #[ cfg( not( kani) ) ]
@@ -861,7 +863,7 @@ mod tests {
861863 use compatibility:: * ;
862864
863865 // A native integer type (u16, i32, etc).
864- trait Native : Arbitrary + FromBytes + AsBytes + Copy + PartialEq + Debug {
866+ trait Native : Arbitrary + FromBytes + IntoBytes + NoCell + Copy + PartialEq + Debug {
865867 const ZERO : Self ;
866868 const MAX_VALUE : Self ;
867869
@@ -898,13 +900,13 @@ mod tests {
898900 }
899901
900902 trait ByteArray :
901- FromBytes + AsBytes + Copy + AsRef < [ u8 ] > + AsMut < [ u8 ] > + Debug + Default + Eq
903+ FromBytes + IntoBytes + NoCell + Copy + AsRef < [ u8 ] > + AsMut < [ u8 ] > + Debug + Default + Eq
902904 {
903905 /// Invert the order of the bytes in the array.
904906 fn invert ( self ) -> Self ;
905907 }
906908
907- trait ByteOrderType : FromBytes + AsBytes + Unaligned + Copy + Eq + Debug {
909+ trait ByteOrderType : FromBytes + IntoBytes + Unaligned + Copy + Eq + Debug {
908910 type Native : Native ;
909911 type ByteArray : ByteArray ;
910912
0 commit comments