Lines Matching defs:IntoBytes
46 //! - [`IntoBytes`] indicates that a type may safely be converted *to* a byte
128 //! `IntoBytes` impls are emitted for all stable SIMD types which exist on the
553 use {FromZeros as FromZeroes, IntoBytes as AsBytes, Ref as LayoutVerified};
1865 /// # `TryFromBytes` is not symmetrical with [`IntoBytes`]
1867 /// There are some types which implement both `TryFromBytes` and [`IntoBytes`],
1869 /// produced by `IntoBytes`. In other words, for some `T: TryFromBytes +
1870 /// IntoBytes`, there exist values of `t: T` such that
1872 /// generally assume that values produced by `IntoBytes` will necessarily be
2300 /// #[derive(TryFromBytes, IntoBytes, KnownLayout)]
2318 /// #[derive(TryFromBytes, IntoBytes, KnownLayout)]
2323 /// #[derive(TryFromBytes, IntoBytes, KnownLayout)]
2327 /// #[derive(TryFromBytes, IntoBytes, KnownLayout)]
2361 Self: KnownLayout + IntoBytes,
2406 /// #[derive(TryFromBytes, IntoBytes, KnownLayout)]
2424 /// #[derive(TryFromBytes, IntoBytes, KnownLayout)]
2429 /// #[derive(TryFromBytes, IntoBytes, KnownLayout)]
2433 /// #[derive(TryFromBytes, IntoBytes, KnownLayout)]
2472 Self: KnownLayout + IntoBytes,
2506 /// #[derive(TryFromBytes, IntoBytes, KnownLayout)]
2524 /// #[derive(TryFromBytes, IntoBytes, KnownLayout)]
2529 /// #[derive(TryFromBytes, IntoBytes, KnownLayout)]
2533 /// #[derive(TryFromBytes, IntoBytes, KnownLayout)]
2572 Self: KnownLayout + IntoBytes,
2933 /// #[derive(TryFromBytes, IntoBytes, KnownLayout)]
2938 /// #[derive(TryFromBytes, IntoBytes, KnownLayout)]
2942 /// #[derive(TryFromBytes, IntoBytes, KnownLayout)]
2977 /// #[derive(TryFromBytes, IntoBytes, KnownLayout)]
3003 Self: KnownLayout<PointerMetadata = usize> + IntoBytes,
3042 /// #[derive(TryFromBytes, IntoBytes, KnownLayout)]
3047 /// #[derive(TryFromBytes, IntoBytes, KnownLayout)]
3051 /// #[derive(TryFromBytes, IntoBytes, KnownLayout)]
3088 /// #[derive(TryFromBytes, IntoBytes, KnownLayout)]
3114 Self: KnownLayout<PointerMetadata = usize> + IntoBytes,
3142 /// #[derive(TryFromBytes, IntoBytes, KnownLayout)]
3147 /// #[derive(TryFromBytes, IntoBytes, KnownLayout)]
3151 /// #[derive(TryFromBytes, IntoBytes, KnownLayout)]
3188 /// #[derive(TryFromBytes, IntoBytes, KnownLayout)]
3214 Self: KnownLayout<PointerMetadata = usize> + IntoBytes,
3462 S: IntoBytes + Immutable + ?Sized,
3490 fn try_mut_from_prefix_suffix<T: IntoBytes + TryFromBytes + KnownLayout + ?Sized>(
3517 S: IntoBytes + Immutable + ?Sized,
4630 /// #[derive(FromBytes, Immutable, IntoBytes, KnownLayout)]
4649 /// #[derive(FromBytes, IntoBytes, KnownLayout, Immutable)]
4682 Self: IntoBytes + KnownLayout,
4720 /// #[derive(FromBytes, Immutable, IntoBytes, KnownLayout)]
4739 /// #[derive(FromBytes, IntoBytes, KnownLayout, Immutable)]
4775 Self: IntoBytes + KnownLayout,
4809 /// #[derive(FromBytes, Immutable, IntoBytes, KnownLayout)]
4826 /// #[derive(FromBytes, IntoBytes, KnownLayout, Immutable)]
4856 Self: IntoBytes + KnownLayout,
5167 /// #[derive(KnownLayout, FromBytes, IntoBytes, Immutable)]
5198 /// #[derive(FromBytes, IntoBytes, Immutable, KnownLayout)]
5223 Self: IntoBytes + KnownLayout<PointerMetadata = usize> + Immutable,
5253 /// #[derive(KnownLayout, FromBytes, IntoBytes, Immutable)]
5288 /// #[derive(FromBytes, IntoBytes, Immutable, KnownLayout)]
5313 Self: IntoBytes + KnownLayout<PointerMetadata = usize>,
5338 /// #[derive(FromBytes, IntoBytes, Immutable)]
5373 /// #[derive(FromBytes, IntoBytes, Immutable, KnownLayout)]
5398 Self: IntoBytes + KnownLayout<PointerMetadata = usize>,
5641 Self: KnownLayout + IntoBytes,
5674 Self: Sized + IntoBytes,
5685 Self: Sized + IntoBytes,
5717 S: IntoBytes + Immutable + ?Sized,
5740 fn mut_from_prefix_suffix<T: FromBytes + IntoBytes + KnownLayout + ?Sized>(
5751 /// Analyzes whether a type is [`IntoBytes`].
5754 /// the [safety conditions] of `IntoBytes` and implements `IntoBytes` if it is
5759 /// # use zerocopy_derive::{IntoBytes};
5760 /// #[derive(IntoBytes)]
5768 /// #[derive(IntoBytes)]
5778 /// [safety conditions]: trait@IntoBytes#safety
5783 /// for `IntoBytes` is implemented, you may get an error like this:
5789 /// 1 | #[derive(IntoBytes)]
5797 /// is illegal for `IntoBytes` types. Consider reducing the alignment of some
5808 /// zerocopy does not support `#[derive(IntoBytes)]` on unions by default.
5809 /// However, implementing `IntoBytes` on a union type is likely sound on all
5811 /// future. You can opt-in to `#[derive(IntoBytes)]` support on unions by
5826 /// demand there is for this feature. If you would like to use `IntoBytes` on
5835 /// determine whether it is sound to implement `IntoBytes` for a given type.
5837 /// manually implement `IntoBytes` for a type yourself, you don't need to read
5841 /// `IntoBytes` for that type:
5843 /// - If the type is a struct, its fields must be [`IntoBytes`]. Additionally:
5845 /// [`IntoBytes`] if its fields are [`IntoBytes`]; else,
5846 /// - if the type is `repr(C)` with at most one field, it is [`IntoBytes`]
5847 /// if its field is [`IntoBytes`]; else,
5848 /// - if the type has no generic parameters, it is [`IntoBytes`] if the type
5853 /// [`IntoBytes`]; else,
5859 /// - Its fields must be [`IntoBytes`].
5868 pub use zerocopy_derive::IntoBytes;
5872 /// Any `IntoBytes` type can be converted to a slice of initialized bytes of the
5879 /// [`#[derive(IntoBytes)]`][derive]; e.g.:
5882 /// # use zerocopy_derive::IntoBytes;
5883 /// #[derive(IntoBytes)]
5891 /// #[derive(IntoBytes)]
5902 /// determine whether a type is `IntoBytes`. See the [derive
5908 /// *This section describes what is required in order for `T: IntoBytes`, and
5910 /// `IntoBytes` manually, and you don't plan on writing unsafe code that
5911 /// operates on `IntoBytes` types, then you don't need to read this section.*
5913 /// If `T: IntoBytes`, then unsafe code may assume that it is sound to treat any
5915 /// marked as `IntoBytes` which violates this contract, it may cause undefined
5918 /// `#[derive(IntoBytes)]` only permits [types which satisfy these
5923 doc = "[derive]: zerocopy_derive::IntoBytes",
5924 doc = "[derive-analysis]: zerocopy_derive::IntoBytes#analysis"
5928 doc = concat!("[derive]: https://docs.rs/zerocopy/", env!("CARGO_PKG_VERSION"), "/zerocopy/derive.IntoBytes.html"),
5929 doc = concat!("[derive-analysis]: https://docs.rs/zerocopy/", env!("CARGO_PKG_VERSION"), "/zerocopy/derive.IntoBytes.html#analysis"),
5933 diagnostic::on_unimplemented(note = "Consider adding `#[derive(IntoBytes)]` to `{Self}`")
5935 pub unsafe trait IntoBytes {
5937 // `IntoBytes` from being object safe. Note that other `IntoBytes` methods
5940 // signatures, or move them out of this trait so that `IntoBytes` is object
5952 /// use zerocopy::IntoBytes;
5955 /// #[derive(IntoBytes, Immutable)]
6013 // - `Self: IntoBytes` ensures that all of the bytes of `slf` are
6032 /// use zerocopy::IntoBytes;
6036 /// #[derive(FromBytes, IntoBytes, Immutable)]
6068 /// See [`IntoBytes::as_bytes`](#method.as_bytes.codegen).
6089 // - `Self: IntoBytes` ensures that all of the bytes of `slf` are
6110 /// use zerocopy::IntoBytes;
6113 /// #[derive(IntoBytes, Immutable)]
6140 /// # use zerocopy::IntoBytes;
6196 /// use zerocopy::IntoBytes;
6199 /// #[derive(IntoBytes, Immutable)]
6226 /// # use zerocopy::IntoBytes;
6284 /// use zerocopy::IntoBytes;
6287 /// #[derive(IntoBytes, Immutable)]
6321 /// # use zerocopy::IntoBytes;
6389 /// use zerocopy::{byteorder::big_endian::U16, FromBytes, IntoBytes};
6393 /// #[derive(FromBytes, IntoBytes, Immutable, KnownLayout)]
6410 /// # use zerocopy::IntoBytes;
6431 #[deprecated(since = "0.8.0", note = "`IntoBytes::as_bytes_mut` was renamed to `as_mut_bytes`")]
6587 /// [`Immutable`] and [`IntoBytes`]; e.g.:
6590 /// # use zerocopy_derive::{ByteEq, Immutable, IntoBytes};
6591 /// #[derive(ByteEq, Immutable, IntoBytes)]
6599 /// #[derive(ByteEq, Immutable, IntoBytes)]
6620 /// [`Immutable`] and [`IntoBytes`]; e.g.:
6623 /// # use zerocopy_derive::{ByteHash, Immutable, IntoBytes};
6624 /// #[derive(ByteHash, Immutable, IntoBytes)]
6632 /// #[derive(ByteHash, Immutable, IntoBytes)]
6660 /// # use zerocopy_derive::{ByteEq, Immutable, IntoBytes};
6661 /// #[derive(ByteEq, Immutable, IntoBytes)]
6728 #[derive(Debug, Eq, PartialEq, FromBytes, IntoBytes, Unaligned, Immutable)]
7470 // Test `IntoBytes::{write_to, write_to_prefix, write_to_suffix}`.
7603 #[derive(IntoBytes, Immutable)]
7607 fn check<S: IntoBytes + Immutable + ?Sized>(source: &S, valid: bool) {
7784 /// Run a series of tests by calling `IntoBytes` methods on `t`.
7792 fn test<T: FromBytes + IntoBytes + Immutable + Debug + Eq + ?Sized, const N: usize>(
7849 #[derive(Debug, Eq, PartialEq, FromBytes, IntoBytes, Immutable)]
7878 #[derive(FromBytes, IntoBytes, Immutable)]
7903 #[derive(IntoBytes, FromBytes, Unaligned)]
7911 assert_impl_all!(Foo<u32>: FromZeros, FromBytes, IntoBytes);
7914 #[derive(IntoBytes, FromBytes, Unaligned)]
7922 assert_impl_all!(Bar<u8, AU64>: FromZeros, FromBytes, IntoBytes, Unaligned);
8138 #[derive(IntoBytes, Immutable)]
8142 fn check<S: IntoBytes + Immutable + ?Sized>(source: &S) {
8199 #[derive(IntoBytes, Immutable)]
8203 fn check<S: IntoBytes + Immutable + ?Sized>(source: &S) {
8241 fn check<S: IntoBytes + Immutable + ?Sized>(source: &S) {