Skip to content

Commit fbf02b9

Browse files
committed
Rename AsBytes to ToBytes
TODO Closes #695
1 parent a8572da commit fbf02b9

File tree

85 files changed

+904
-948
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+904
-948
lines changed

src/byteorder.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
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`], [`ToBytes`], 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
@@ -35,10 +35,10 @@
3535
//!
3636
//! ```rust,edition2021
3737
//! # #[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::{ToBytes, ByteSlice, FromBytes, FromZeros, NoCell, Ref, Unaligned};
3939
//! use zerocopy::byteorder::network_endian::U16;
4040
//!
41-
//! #[derive(FromZeros, FromBytes, AsBytes, NoCell, Unaligned)]
41+
//! #[derive(FromZeros, FromBytes, ToBytes, NoCell, Unaligned)]
4242
//! #[repr(C)]
4343
//! struct UdpHeader {
4444
//! src_port: U16,
@@ -265,18 +265,18 @@ order to uphold the invariants that a) the layout of `", stringify!($name), "`
265265
has endianness `O` and that, b) the layout of `", stringify!($native), "` has
266266
the platform's native endianness.
267267
268-
`", stringify!($name), "` implements [`FromBytes`], [`AsBytes`], and [`Unaligned`],
268+
`", stringify!($name), "` implements [`FromBytes`], [`ToBytes`], and [`Unaligned`],
269269
making it useful for parsing and serialization. See the module documentation for an
270270
example of how it can be used for parsing UDP packets.
271271
272272
[`new`]: crate::byteorder::", stringify!($name), "::new
273273
[`get`]: crate::byteorder::", stringify!($name), "::get
274274
[`set`]: crate::byteorder::", stringify!($name), "::set
275275
[`FromBytes`]: crate::FromBytes
276-
[`AsBytes`]: crate::AsBytes
276+
[`ToBytes`]: crate::ToBytes
277277
[`Unaligned`]: crate::Unaligned"),
278278
#[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, ToBytes, Unaligned))]
280280
#[repr(transparent)]
281281
pub struct $name<O>([u8; $bytes], PhantomData<O>);
282282
}
@@ -288,12 +288,12 @@ example of how it can be used for parsing UDP packets.
288288
/// SAFETY:
289289
/// `$name<O>` is `repr(transparent)`, and so it has the same layout
290290
/// 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`, `ToBytes`, and
292292
/// `Unaligned`.
293293
impl_or_verify!(O => NoCell for $name<O>);
294294
impl_or_verify!(O => FromZeros for $name<O>);
295295
impl_or_verify!(O => FromBytes for $name<O>);
296-
impl_or_verify!(O => AsBytes for $name<O>);
296+
impl_or_verify!(O => ToBytes for $name<O>);
297297
impl_or_verify!(O => Unaligned for $name<O>);
298298
}
299299

@@ -607,7 +607,7 @@ mod tests {
607607

608608
use {
609609
super::*,
610-
crate::{AsBytes, FromBytes, Unaligned},
610+
crate::{FromBytes, ToBytes, Unaligned},
611611
};
612612

613613
#[cfg(not(kani))]
@@ -655,7 +655,7 @@ mod tests {
655655
use compatibility::*;
656656

657657
// A native integer type (u16, i32, etc).
658-
trait Native: Arbitrary + FromBytes + AsBytes + NoCell + Copy + PartialEq + Debug {
658+
trait Native: Arbitrary + FromBytes + ToBytes + NoCell + Copy + PartialEq + Debug {
659659
const ZERO: Self;
660660
const MAX_VALUE: Self;
661661

@@ -692,13 +692,13 @@ mod tests {
692692
}
693693

694694
trait ByteArray:
695-
FromBytes + AsBytes + NoCell + Copy + AsRef<[u8]> + AsMut<[u8]> + Debug + Default + Eq
695+
FromBytes + ToBytes + NoCell + Copy + AsRef<[u8]> + AsMut<[u8]> + Debug + Default + Eq
696696
{
697697
/// Invert the order of the bytes in the array.
698698
fn invert(self) -> Self;
699699
}
700700

701-
trait ByteOrderType: FromBytes + AsBytes + Unaligned + Copy + Eq + Debug {
701+
trait ByteOrderType: FromBytes + ToBytes + Unaligned + Copy + Eq + Debug {
702702
type Native: Native;
703703
type ByteArray: ByteArray;
704704

0 commit comments

Comments
 (0)