16
16
//! this module - [`U16`], [`I16`], [`U32`], [`F64`], etc. Unlike their native
17
17
//! counterparts, these types have alignment 1, and take a type parameter
18
18
//! 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.
20
20
//!
21
21
//! These two properties, taken together, make these types useful for defining
22
22
//! data structures whose memory layout matches a wire format such as that of a
35
35
//!
36
36
//! ```rust,edition2021
37
37
//! # #[cfg(feature = "derive")] { // This example uses derives, and won't compile without them
38
- //! use zerocopy::{AsBytes , ByteSlice, FromBytes, FromZeros, NoCell, Ref, Unaligned};
38
+ //! use zerocopy::{IntoBytes , ByteSlice, FromBytes, FromZeros, NoCell, Ref, Unaligned};
39
39
//! use zerocopy::byteorder::network_endian::U16;
40
40
//!
41
- //! #[derive(FromZeros, FromBytes, AsBytes , NoCell, Unaligned)]
41
+ //! #[derive(FromZeros, FromBytes, IntoBytes , NoCell, Unaligned)]
42
42
//! #[repr(C)]
43
43
//! struct UdpHeader {
44
44
//! src_port: U16,
@@ -265,18 +265,18 @@ order to uphold the invariants that a) the layout of `", stringify!($name), "`
265
265
has endianness `O` and that, b) the layout of `" , stringify!( $native) , "` has
266
266
the platform's native endianness.
267
267
268
- `" , stringify!( $name) , "` implements [`FromBytes`], [`AsBytes `], and [`Unaligned`],
268
+ `" , stringify!( $name) , "` implements [`FromBytes`], [`IntoBytes `], and [`Unaligned`],
269
269
making it useful for parsing and serialization. See the module documentation for an
270
270
example of how it can be used for parsing UDP packets.
271
271
272
272
[`new`]: crate::byteorder::" , stringify!( $name) , "::new
273
273
[`get`]: crate::byteorder::" , stringify!( $name) , "::get
274
274
[`set`]: crate::byteorder::" , stringify!( $name) , "::set
275
275
[`FromBytes`]: crate::FromBytes
276
- [`AsBytes `]: crate::AsBytes
276
+ [`IntoBytes `]: crate::IntoBytes
277
277
[`Unaligned`]: crate::Unaligned" ) ,
278
278
#[ derive( Copy , Clone , Eq , PartialEq , Hash ) ]
279
- #[ cfg_attr( any( feature = "derive" , test) , derive( KnownLayout , NoCell , FromZeros , FromBytes , AsBytes , Unaligned ) ) ]
279
+ #[ cfg_attr( any( feature = "derive" , test) , derive( KnownLayout , NoCell , FromZeros , FromBytes , IntoBytes , Unaligned ) ) ]
280
280
#[ repr( transparent) ]
281
281
pub struct $name<O >( [ u8 ; $bytes] , PhantomData <O >) ;
282
282
}
@@ -288,12 +288,12 @@ example of how it can be used for parsing UDP packets.
288
288
/// SAFETY:
289
289
/// `$name<O>` is `repr(transparent)`, and so it has the same layout
290
290
/// as its only non-zero field, which is a `u8` array. `u8` arrays
291
- /// are `NoCell`, `FromZeros`, `FromBytes`, `AsBytes `, and
291
+ /// are `NoCell`, `FromZeros`, `FromBytes`, `IntoBytes `, and
292
292
/// `Unaligned`.
293
293
impl_or_verify!( O => NoCell for $name<O >) ;
294
294
impl_or_verify!( O => FromZeros for $name<O >) ;
295
295
impl_or_verify!( O => FromBytes for $name<O >) ;
296
- impl_or_verify!( O => AsBytes for $name<O >) ;
296
+ impl_or_verify!( O => IntoBytes for $name<O >) ;
297
297
impl_or_verify!( O => Unaligned for $name<O >) ;
298
298
}
299
299
@@ -607,7 +607,7 @@ mod tests {
607
607
608
608
use {
609
609
super :: * ,
610
- crate :: { AsBytes , FromBytes , Unaligned } ,
610
+ crate :: { FromBytes , IntoBytes , Unaligned } ,
611
611
} ;
612
612
613
613
#[ cfg( not( kani) ) ]
@@ -655,7 +655,7 @@ mod tests {
655
655
use compatibility:: * ;
656
656
657
657
// A native integer type (u16, i32, etc).
658
- trait Native : Arbitrary + FromBytes + AsBytes + NoCell + Copy + PartialEq + Debug {
658
+ trait Native : Arbitrary + FromBytes + IntoBytes + NoCell + Copy + PartialEq + Debug {
659
659
const ZERO : Self ;
660
660
const MAX_VALUE : Self ;
661
661
@@ -692,13 +692,13 @@ mod tests {
692
692
}
693
693
694
694
trait ByteArray :
695
- FromBytes + AsBytes + NoCell + Copy + AsRef < [ u8 ] > + AsMut < [ u8 ] > + Debug + Default + Eq
695
+ FromBytes + IntoBytes + NoCell + Copy + AsRef < [ u8 ] > + AsMut < [ u8 ] > + Debug + Default + Eq
696
696
{
697
697
/// Invert the order of the bytes in the array.
698
698
fn invert ( self ) -> Self ;
699
699
}
700
700
701
- trait ByteOrderType : FromBytes + AsBytes + Unaligned + Copy + Eq + Debug {
701
+ trait ByteOrderType : FromBytes + IntoBytes + Unaligned + Copy + Eq + Debug {
702
702
type Native : Native ;
703
703
type ByteArray : ByteArray ;
704
704
0 commit comments