Skip to main content

FromBytes

Trait FromBytes 

Source
pub unsafe trait FromBytes: FromZeros {
Show 16 methods // Provided methods fn ref_from_bytes( source: &[u8], ) -> Result<&Self, ConvertError<AlignmentError<&[u8], Self>, SizeError<&[u8], Self>, !>> where Self: KnownLayout + Immutable { ... } fn ref_from_prefix( source: &[u8], ) -> Result<(&Self, &[u8]), ConvertError<AlignmentError<&[u8], Self>, SizeError<&[u8], Self>, !>> where Self: KnownLayout + Immutable { ... } fn ref_from_suffix( source: &[u8], ) -> Result<(&[u8], &Self), ConvertError<AlignmentError<&[u8], Self>, SizeError<&[u8], Self>, !>> where Self: Immutable + KnownLayout { ... } fn mut_from_bytes( source: &mut [u8], ) -> Result<&mut Self, ConvertError<AlignmentError<&mut [u8], Self>, SizeError<&mut [u8], Self>, !>> where Self: IntoBytes + KnownLayout { ... } fn mut_from_prefix( source: &mut [u8], ) -> Result<(&mut Self, &mut [u8]), ConvertError<AlignmentError<&mut [u8], Self>, SizeError<&mut [u8], Self>, !>> where Self: IntoBytes + KnownLayout { ... } fn mut_from_suffix( source: &mut [u8], ) -> Result<(&mut [u8], &mut Self), ConvertError<AlignmentError<&mut [u8], Self>, SizeError<&mut [u8], Self>, !>> where Self: IntoBytes + KnownLayout { ... } fn ref_from_bytes_with_elems( source: &[u8], count: usize, ) -> Result<&Self, ConvertError<AlignmentError<&[u8], Self>, SizeError<&[u8], Self>, !>> where Self: KnownLayout<PointerMetadata = usize> + Immutable { ... } fn ref_from_prefix_with_elems( source: &[u8], count: usize, ) -> Result<(&Self, &[u8]), ConvertError<AlignmentError<&[u8], Self>, SizeError<&[u8], Self>, !>> where Self: KnownLayout<PointerMetadata = usize> + Immutable { ... } fn ref_from_suffix_with_elems( source: &[u8], count: usize, ) -> Result<(&[u8], &Self), ConvertError<AlignmentError<&[u8], Self>, SizeError<&[u8], Self>, !>> where Self: KnownLayout<PointerMetadata = usize> + Immutable { ... } fn mut_from_bytes_with_elems( source: &mut [u8], count: usize, ) -> Result<&mut Self, ConvertError<AlignmentError<&mut [u8], Self>, SizeError<&mut [u8], Self>, !>> where Self: IntoBytes + KnownLayout<PointerMetadata = usize> + Immutable { ... } fn mut_from_prefix_with_elems( source: &mut [u8], count: usize, ) -> Result<(&mut Self, &mut [u8]), ConvertError<AlignmentError<&mut [u8], Self>, SizeError<&mut [u8], Self>, !>> where Self: IntoBytes + KnownLayout<PointerMetadata = usize> { ... } fn mut_from_suffix_with_elems( source: &mut [u8], count: usize, ) -> Result<(&mut [u8], &mut Self), ConvertError<AlignmentError<&mut [u8], Self>, SizeError<&mut [u8], Self>, !>> where Self: IntoBytes + KnownLayout<PointerMetadata = usize> { ... } fn read_from_bytes(source: &[u8]) -> Result<Self, SizeError<&[u8], Self>> where Self: Sized { ... } fn read_from_prefix( source: &[u8], ) -> Result<(Self, &[u8]), SizeError<&[u8], Self>> where Self: Sized { ... } fn read_from_suffix( source: &[u8], ) -> Result<(&[u8], Self), SizeError<&[u8], Self>> where Self: Sized { ... } fn read_from_io<R>(src: R) -> Result<Self, Error> where Self: Sized, R: Read { ... }
}
Expand description

Types for which any bit pattern is valid.

Any memory region of the appropriate length which contains initialized bytes can be viewed as any FromBytes type with no runtime overhead. This is useful for efficiently parsing bytes as structured data.

§Warning: Padding bytes

Note that, when a value is moved or copied, only the non-padding bytes of that value are guaranteed to be preserved. It is unsound to assume that values written to padding bytes are preserved after a move or copy. For example, the following is unsound:

use core::mem::{size_of, transmute};
use zerocopy::FromZeros;

// Assume `Foo` is a type with padding bytes.
#[derive(FromZeros, Default)]
struct Foo {
    ...
}

let mut foo: Foo = Foo::default();
FromZeros::zero(&mut foo);
// UNSOUND: Although `FromZeros::zero` writes zeros to all bytes of `foo`,
// those writes are not guaranteed to be preserved in padding bytes when
// `foo` is moved, so this may expose padding bytes as `u8`s.
let foo_bytes: [u8; size_of::<Foo>()] = unsafe { transmute(foo) };

§Implementation

Do not implement this trait yourself! Instead, use #[derive(FromBytes)]; e.g.:

#[derive(FromBytes)]
struct MyStruct {
    ...
}

#[derive(FromBytes)]
#[repr(u8)]
enum MyEnum {
    ...
}

#[derive(FromBytes, Immutable)]
union MyUnion {
    ...
}

This derive performs a sophisticated, compile-time safety analysis to determine whether a type is FromBytes.

§Safety

This section describes what is required in order for T: FromBytes, and what unsafe code may assume of such types. If you don’t plan on implementing FromBytes manually, and you don’t plan on writing unsafe code that operates on FromBytes types, then you don’t need to read this section.

If T: FromBytes, then unsafe code may assume that it is sound to produce a T whose bytes are initialized to any sequence of valid u8s (in other words, any byte value which is not uninitialized). If a type is marked as FromBytes which violates this contract, it may cause undefined behavior.

#[derive(FromBytes)] only permits types which satisfy these requirements.

Provided Methods§

Source

fn ref_from_bytes( source: &[u8], ) -> Result<&Self, ConvertError<AlignmentError<&[u8], Self>, SizeError<&[u8], Self>, !>>
where Self: KnownLayout + Immutable,

Interprets the given source as a &Self.

This method attempts to return a reference to source interpreted as a Self. If the length of source is not a valid size of Self, or if source is not appropriately aligned, this returns Err. If Self: Unaligned, you can infallibly discard the alignment error.

Self may be a sized type, a slice, or a slice DST.

§Compile-Time Assertions

This method cannot yet be used on unsized types whose dynamically-sized component is zero-sized. Attempting to use this method on such types results in a compile-time assertion error; e.g.:

ⓘ
use zerocopy::*;

#[derive(FromBytes, Immutable, KnownLayout)]
#[repr(C)]
struct ZSTy {
    leading_sized: u16,
    trailing_dst: [()],
}

let _ = ZSTy::ref_from_bytes(0u16.as_bytes()); // ⚠ Compile Error!
§Examples
use zerocopy::FromBytes;

#[derive(FromBytes, KnownLayout, Immutable)]
#[repr(C)]
struct PacketHeader {
    src_port: [u8; 2],
    dst_port: [u8; 2],
    length: [u8; 2],
    checksum: [u8; 2],
}

#[derive(FromBytes, KnownLayout, Immutable)]
#[repr(C)]
struct Packet {
    header: PacketHeader,
    body: [u8],
}

// These bytes encode a `Packet`.
let bytes = &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11][..];

let packet = Packet::ref_from_bytes(bytes).unwrap();

assert_eq!(packet.header.src_port, [0, 1]);
assert_eq!(packet.header.dst_port, [2, 3]);
assert_eq!(packet.header.length, [4, 5]);
assert_eq!(packet.header.checksum, [6, 7]);
assert_eq!(packet.body, [8, 9, 10, 11]);
Source

fn ref_from_prefix( source: &[u8], ) -> Result<(&Self, &[u8]), ConvertError<AlignmentError<&[u8], Self>, SizeError<&[u8], Self>, !>>
where Self: KnownLayout + Immutable,

Interprets the prefix of the given source as a &Self without copying.

This method computes the largest possible size of Self that can fit in the leading bytes of source, then attempts to return both a reference to those bytes interpreted as a Self, and a reference to the remaining bytes. If there are insufficient bytes, or if source is not appropriately aligned, this returns Err. If Self: Unaligned, you can infallibly discard the alignment error.

Self may be a sized type, a slice, or a slice DST.

§Compile-Time Assertions

This method cannot yet be used on unsized types whose dynamically-sized component is zero-sized. See ref_from_prefix_with_elems, which does support such types. Attempting to use this method on such types results in a compile-time assertion error; e.g.:

ⓘ
use zerocopy::*;

#[derive(FromBytes, Immutable, KnownLayout)]
#[repr(C)]
struct ZSTy {
    leading_sized: u16,
    trailing_dst: [()],
}

let _ = ZSTy::ref_from_prefix(0u16.as_bytes()); // ⚠ Compile Error!
§Examples
use zerocopy::FromBytes;

#[derive(FromBytes, KnownLayout, Immutable)]
#[repr(C)]
struct PacketHeader {
    src_port: [u8; 2],
    dst_port: [u8; 2],
    length: [u8; 2],
    checksum: [u8; 2],
}

#[derive(FromBytes, KnownLayout, Immutable)]
#[repr(C)]
struct Packet {
    header: PacketHeader,
    body: [[u8; 2]],
}

// These are more bytes than are needed to encode a `Packet`.
let bytes = &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14][..];

let (packet, suffix) = Packet::ref_from_prefix(bytes).unwrap();

assert_eq!(packet.header.src_port, [0, 1]);
assert_eq!(packet.header.dst_port, [2, 3]);
assert_eq!(packet.header.length, [4, 5]);
assert_eq!(packet.header.checksum, [6, 7]);
assert_eq!(packet.body, [[8, 9], [10, 11], [12, 13]]);
assert_eq!(suffix, &[14u8][..]);
Source

fn ref_from_suffix( source: &[u8], ) -> Result<(&[u8], &Self), ConvertError<AlignmentError<&[u8], Self>, SizeError<&[u8], Self>, !>>
where Self: Immutable + KnownLayout,

Interprets the suffix of the given bytes as a &Self.

This method computes the largest possible size of Self that can fit in the trailing bytes of source, then attempts to return both a reference to those bytes interpreted as a Self, and a reference to the preceding bytes. If there are insufficient bytes, or if that suffix of source is not appropriately aligned, this returns Err. If Self: Unaligned, you can infallibly discard the alignment error.

Self may be a sized type, a slice, or a slice DST.

§Compile-Time Assertions

This method cannot yet be used on unsized types whose dynamically-sized component is zero-sized. See ref_from_suffix_with_elems, which does support such types. Attempting to use this method on such types results in a compile-time assertion error; e.g.:

ⓘ
use zerocopy::*;

#[derive(FromBytes, Immutable, KnownLayout)]
#[repr(C)]
struct ZSTy {
    leading_sized: u16,
    trailing_dst: [()],
}

let _ = ZSTy::ref_from_suffix(0u16.as_bytes()); // ⚠ Compile Error!
§Examples
use zerocopy::FromBytes;

#[derive(FromBytes, Immutable, KnownLayout)]
#[repr(C)]
struct PacketTrailer {
    frame_check_sequence: [u8; 4],
}

// These are more bytes than are needed to encode a `PacketTrailer`.
let bytes = &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9][..];

let (prefix, trailer) = PacketTrailer::ref_from_suffix(bytes).unwrap();

assert_eq!(prefix, &[0, 1, 2, 3, 4, 5][..]);
assert_eq!(trailer.frame_check_sequence, [6, 7, 8, 9]);
Source

fn mut_from_bytes( source: &mut [u8], ) -> Result<&mut Self, ConvertError<AlignmentError<&mut [u8], Self>, SizeError<&mut [u8], Self>, !>>
where Self: IntoBytes + KnownLayout,

Interprets the given source as a &mut Self.

This method attempts to return a reference to source interpreted as a Self. If the length of source is not a valid size of Self, or if source is not appropriately aligned, this returns Err. If Self: Unaligned, you can infallibly discard the alignment error.

Self may be a sized type, a slice, or a slice DST.

§Compile-Time Assertions

This method cannot yet be used on unsized types whose dynamically-sized component is zero-sized. See mut_from_prefix_with_elems, which does support such types. Attempting to use this method on such types results in a compile-time assertion error; e.g.:

ⓘ
use zerocopy::*;

#[derive(FromBytes, Immutable, IntoBytes, KnownLayout)]
#[repr(C, packed)]
struct ZSTy {
    leading_sized: [u8; 2],
    trailing_dst: [()],
}

let mut source = [85, 85];
let _ = ZSTy::mut_from_bytes(&mut source[..]); // ⚠ Compile Error!
§Examples
use zerocopy::FromBytes;

#[derive(FromBytes, IntoBytes, KnownLayout, Immutable)]
#[repr(C)]
struct PacketHeader {
    src_port: [u8; 2],
    dst_port: [u8; 2],
    length: [u8; 2],
    checksum: [u8; 2],
}

// These bytes encode a `PacketHeader`.
let bytes = &mut [0, 1, 2, 3, 4, 5, 6, 7][..];

let header = PacketHeader::mut_from_bytes(bytes).unwrap();

assert_eq!(header.src_port, [0, 1]);
assert_eq!(header.dst_port, [2, 3]);
assert_eq!(header.length, [4, 5]);
assert_eq!(header.checksum, [6, 7]);

header.checksum = [0, 0];

assert_eq!(bytes, [0, 1, 2, 3, 4, 5, 0, 0]);
§ Code Generation

See FromBytes::ref_from_bytes.

Source

fn mut_from_prefix( source: &mut [u8], ) -> Result<(&mut Self, &mut [u8]), ConvertError<AlignmentError<&mut [u8], Self>, SizeError<&mut [u8], Self>, !>>
where Self: IntoBytes + KnownLayout,

Interprets the prefix of the given source as a &mut Self without copying.

This method computes the largest possible size of Self that can fit in the leading bytes of source, then attempts to return both a reference to those bytes interpreted as a Self, and a reference to the remaining bytes. If there are insufficient bytes, or if source is not appropriately aligned, this returns Err. If Self: Unaligned, you can infallibly discard the alignment error.

Self may be a sized type, a slice, or a slice DST.

§Compile-Time Assertions

This method cannot yet be used on unsized types whose dynamically-sized component is zero-sized. See mut_from_suffix_with_elems, which does support such types. Attempting to use this method on such types results in a compile-time assertion error; e.g.:

ⓘ
use zerocopy::*;

#[derive(FromBytes, Immutable, IntoBytes, KnownLayout)]
#[repr(C, packed)]
struct ZSTy {
    leading_sized: [u8; 2],
    trailing_dst: [()],
}

let mut source = [85, 85];
let _ = ZSTy::mut_from_prefix(&mut source[..]); // ⚠ Compile Error!
§Examples
use zerocopy::FromBytes;

#[derive(FromBytes, IntoBytes, KnownLayout, Immutable)]
#[repr(C)]
struct PacketHeader {
    src_port: [u8; 2],
    dst_port: [u8; 2],
    length: [u8; 2],
    checksum: [u8; 2],
}

// These are more bytes than are needed to encode a `PacketHeader`.
let bytes = &mut [0, 1, 2, 3, 4, 5, 6, 7, 8, 9][..];

let (header, body) = PacketHeader::mut_from_prefix(bytes).unwrap();

assert_eq!(header.src_port, [0, 1]);
assert_eq!(header.dst_port, [2, 3]);
assert_eq!(header.length, [4, 5]);
assert_eq!(header.checksum, [6, 7]);
assert_eq!(body, &[8, 9][..]);

header.checksum = [0, 0];
body.fill(1);

assert_eq!(bytes, [0, 1, 2, 3, 4, 5, 0, 0, 1, 1]);
§ Code Generation

See FromBytes::ref_from_prefix.

Source

fn mut_from_suffix( source: &mut [u8], ) -> Result<(&mut [u8], &mut Self), ConvertError<AlignmentError<&mut [u8], Self>, SizeError<&mut [u8], Self>, !>>
where Self: IntoBytes + KnownLayout,

Interprets the suffix of the given source as a &mut Self without copying.

This method computes the largest possible size of Self that can fit in the trailing bytes of source, then attempts to return both a reference to those bytes interpreted as a Self, and a reference to the preceding bytes. If there are insufficient bytes, or if that suffix of source is not appropriately aligned, this returns Err. If Self: Unaligned, you can infallibly discard the alignment error.

Self may be a sized type, a slice, or a slice DST.

§Compile-Time Assertions

This method cannot yet be used on unsized types whose dynamically-sized component is zero-sized. Attempting to use this method on such types results in a compile-time assertion error; e.g.:

ⓘ
use zerocopy::*;

#[derive(FromBytes, Immutable, IntoBytes, KnownLayout)]
#[repr(C, packed)]
struct ZSTy {
    leading_sized: [u8; 2],
    trailing_dst: [()],
}

let mut source = [85, 85];
let _ = ZSTy::mut_from_suffix(&mut source[..]); // ⚠ Compile Error!
§Examples
use zerocopy::FromBytes;

#[derive(FromBytes, IntoBytes, KnownLayout, Immutable)]
#[repr(C)]
struct PacketTrailer {
    frame_check_sequence: [u8; 4],
}

// These are more bytes than are needed to encode a `PacketTrailer`.
let bytes = &mut [0, 1, 2, 3, 4, 5, 6, 7, 8, 9][..];

let (prefix, trailer) = PacketTrailer::mut_from_suffix(bytes).unwrap();

assert_eq!(prefix, &[0u8, 1, 2, 3, 4, 5][..]);
assert_eq!(trailer.frame_check_sequence, [6, 7, 8, 9]);

prefix.fill(0);
trailer.frame_check_sequence.fill(1);

assert_eq!(bytes, [0, 0, 0, 0, 0, 0, 1, 1, 1, 1]);
§ Code Generation

See FromBytes::ref_from_suffix.

Source

fn ref_from_bytes_with_elems( source: &[u8], count: usize, ) -> Result<&Self, ConvertError<AlignmentError<&[u8], Self>, SizeError<&[u8], Self>, !>>
where Self: KnownLayout<PointerMetadata = usize> + Immutable,

Interprets the given source as a &Self with a DST length equal to count.

This method attempts to return a reference to source interpreted as a Self with count trailing elements. If the length of source is not equal to the size of Self with count elements, or if source is not appropriately aligned, this returns Err. If Self: Unaligned, you can infallibly discard the alignment error.

§Examples
use zerocopy::FromBytes;

#[derive(FromBytes, Immutable)]
#[repr(C)]
struct Pixel {
    r: u8,
    g: u8,
    b: u8,
    a: u8,
}

let bytes = &[0, 1, 2, 3, 4, 5, 6, 7][..];

let pixels = <[Pixel]>::ref_from_bytes_with_elems(bytes, 2).unwrap();

assert_eq!(pixels, &[
    Pixel { r: 0, g: 1, b: 2, a: 3 },
    Pixel { r: 4, g: 5, b: 6, a: 7 },
]);

Since an explicit count is provided, this method supports types with zero-sized trailing slice elements. Methods such as ref_from_bytes which do not take an explicit count do not support such types.

use zerocopy::*;

#[derive(FromBytes, Immutable, KnownLayout)]
#[repr(C)]
struct ZSTy {
    leading_sized: [u8; 2],
    trailing_dst: [()],
}

let src = &[85, 85][..];
let zsty = ZSTy::ref_from_bytes_with_elems(src, 42).unwrap();
assert_eq!(zsty.trailing_dst.len(), 42);
Source

fn ref_from_prefix_with_elems( source: &[u8], count: usize, ) -> Result<(&Self, &[u8]), ConvertError<AlignmentError<&[u8], Self>, SizeError<&[u8], Self>, !>>
where Self: KnownLayout<PointerMetadata = usize> + Immutable,

Interprets the prefix of the given source as a DST &Self with length equal to count.

This method attempts to return a reference to the prefix of source interpreted as a Self with count trailing elements, and a reference to the remaining bytes. If there are insufficient bytes, or if source is not appropriately aligned, this returns Err. If Self: Unaligned, you can infallibly discard the alignment error.

§Examples
use zerocopy::FromBytes;

#[derive(FromBytes, Immutable)]
#[repr(C)]
struct Pixel {
    r: u8,
    g: u8,
    b: u8,
    a: u8,
}

// These are more bytes than are needed to encode two `Pixel`s.
let bytes = &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9][..];

let (pixels, suffix) = <[Pixel]>::ref_from_prefix_with_elems(bytes, 2).unwrap();

assert_eq!(pixels, &[
    Pixel { r: 0, g: 1, b: 2, a: 3 },
    Pixel { r: 4, g: 5, b: 6, a: 7 },
]);

assert_eq!(suffix, &[8, 9]);

Since an explicit count is provided, this method supports types with zero-sized trailing slice elements. Methods such as ref_from_prefix which do not take an explicit count do not support such types.

use zerocopy::*;

#[derive(FromBytes, Immutable, KnownLayout)]
#[repr(C)]
struct ZSTy {
    leading_sized: [u8; 2],
    trailing_dst: [()],
}

let src = &[85, 85][..];
let (zsty, _) = ZSTy::ref_from_prefix_with_elems(src, 42).unwrap();
assert_eq!(zsty.trailing_dst.len(), 42);
Source

fn ref_from_suffix_with_elems( source: &[u8], count: usize, ) -> Result<(&[u8], &Self), ConvertError<AlignmentError<&[u8], Self>, SizeError<&[u8], Self>, !>>
where Self: KnownLayout<PointerMetadata = usize> + Immutable,

Interprets the suffix of the given source as a DST &Self with length equal to count.

This method attempts to return a reference to the suffix of source interpreted as a Self with count trailing elements, and a reference to the preceding bytes. If there are insufficient bytes, or if that suffix of source is not appropriately aligned, this returns Err. If Self: Unaligned, you can infallibly discard the alignment error.

§Examples
use zerocopy::FromBytes;

#[derive(FromBytes, Immutable)]
#[repr(C)]
struct Pixel {
    r: u8,
    g: u8,
    b: u8,
    a: u8,
}

// These are more bytes than are needed to encode two `Pixel`s.
let bytes = &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9][..];

let (prefix, pixels) = <[Pixel]>::ref_from_suffix_with_elems(bytes, 2).unwrap();

assert_eq!(prefix, &[0, 1]);

assert_eq!(pixels, &[
    Pixel { r: 2, g: 3, b: 4, a: 5 },
    Pixel { r: 6, g: 7, b: 8, a: 9 },
]);

Since an explicit count is provided, this method supports types with zero-sized trailing slice elements. Methods such as ref_from_suffix which do not take an explicit count do not support such types.

use zerocopy::*;

#[derive(FromBytes, Immutable, KnownLayout)]
#[repr(C)]
struct ZSTy {
    leading_sized: [u8; 2],
    trailing_dst: [()],
}

let src = &[85, 85][..];
let (_, zsty) = ZSTy::ref_from_suffix_with_elems(src, 42).unwrap();
assert_eq!(zsty.trailing_dst.len(), 42);
Source

fn mut_from_bytes_with_elems( source: &mut [u8], count: usize, ) -> Result<&mut Self, ConvertError<AlignmentError<&mut [u8], Self>, SizeError<&mut [u8], Self>, !>>
where Self: IntoBytes + KnownLayout<PointerMetadata = usize> + Immutable,

Interprets the given source as a &mut Self with a DST length equal to count.

This method attempts to return a reference to source interpreted as a Self with count trailing elements. If the length of source is not equal to the size of Self with count elements, or if source is not appropriately aligned, this returns Err. If Self: Unaligned, you can infallibly discard the alignment error.

§Examples
use zerocopy::FromBytes;

#[derive(KnownLayout, FromBytes, IntoBytes, Immutable)]
#[repr(C)]
struct Pixel {
    r: u8,
    g: u8,
    b: u8,
    a: u8,
}

let bytes = &mut [0, 1, 2, 3, 4, 5, 6, 7][..];

let pixels = <[Pixel]>::mut_from_bytes_with_elems(bytes, 2).unwrap();

assert_eq!(pixels, &[
    Pixel { r: 0, g: 1, b: 2, a: 3 },
    Pixel { r: 4, g: 5, b: 6, a: 7 },
]);

pixels[1] = Pixel { r: 0, g: 0, b: 0, a: 0 };

assert_eq!(bytes, [0, 1, 2, 3, 0, 0, 0, 0]);

Since an explicit count is provided, this method supports types with zero-sized trailing slice elements. Methods such as mut_from_bytes which do not take an explicit count do not support such types.

use zerocopy::*;

#[derive(FromBytes, IntoBytes, Immutable, KnownLayout)]
#[repr(C, packed)]
struct ZSTy {
    leading_sized: [u8; 2],
    trailing_dst: [()],
}

let src = &mut [85, 85][..];
let zsty = ZSTy::mut_from_bytes_with_elems(src, 42).unwrap();
assert_eq!(zsty.trailing_dst.len(), 42);
§ Code Generation

See TryFromBytes::ref_from_bytes_with_elems.

Source

fn mut_from_prefix_with_elems( source: &mut [u8], count: usize, ) -> Result<(&mut Self, &mut [u8]), ConvertError<AlignmentError<&mut [u8], Self>, SizeError<&mut [u8], Self>, !>>
where Self: IntoBytes + KnownLayout<PointerMetadata = usize>,

Interprets the prefix of the given source as a &mut Self with DST length equal to count.

This method attempts to return a reference to the prefix of source interpreted as a Self with count trailing elements, and a reference to the preceding bytes. If there are insufficient bytes, or if source is not appropriately aligned, this returns Err. If Self: Unaligned, you can infallibly discard the alignment error.

§Examples
use zerocopy::FromBytes;

#[derive(KnownLayout, FromBytes, IntoBytes, Immutable)]
#[repr(C)]
struct Pixel {
    r: u8,
    g: u8,
    b: u8,
    a: u8,
}

// These are more bytes than are needed to encode two `Pixel`s.
let bytes = &mut [0, 1, 2, 3, 4, 5, 6, 7, 8, 9][..];

let (pixels, suffix) = <[Pixel]>::mut_from_prefix_with_elems(bytes, 2).unwrap();

assert_eq!(pixels, &[
    Pixel { r: 0, g: 1, b: 2, a: 3 },
    Pixel { r: 4, g: 5, b: 6, a: 7 },
]);

assert_eq!(suffix, &[8, 9]);

pixels[1] = Pixel { r: 0, g: 0, b: 0, a: 0 };
suffix.fill(1);

assert_eq!(bytes, [0, 1, 2, 3, 0, 0, 0, 0, 1, 1]);

Since an explicit count is provided, this method supports types with zero-sized trailing slice elements. Methods such as mut_from_prefix which do not take an explicit count do not support such types.

use zerocopy::*;

#[derive(FromBytes, IntoBytes, Immutable, KnownLayout)]
#[repr(C, packed)]
struct ZSTy {
    leading_sized: [u8; 2],
    trailing_dst: [()],
}

let src = &mut [85, 85][..];
let (zsty, _) = ZSTy::mut_from_prefix_with_elems(src, 42).unwrap();
assert_eq!(zsty.trailing_dst.len(), 42);
§ Code Generation

See TryFromBytes::ref_from_prefix_with_elems.

Source

fn mut_from_suffix_with_elems( source: &mut [u8], count: usize, ) -> Result<(&mut [u8], &mut Self), ConvertError<AlignmentError<&mut [u8], Self>, SizeError<&mut [u8], Self>, !>>
where Self: IntoBytes + KnownLayout<PointerMetadata = usize>,

Interprets the suffix of the given source as a &mut Self with DST length equal to count.

This method attempts to return a reference to the suffix of source interpreted as a Self with count trailing elements, and a reference to the remaining bytes. If there are insufficient bytes, or if that suffix of source is not appropriately aligned, this returns Err. If Self: Unaligned, you can infallibly discard the alignment error.

§Examples
use zerocopy::FromBytes;

#[derive(FromBytes, IntoBytes, Immutable)]
#[repr(C)]
struct Pixel {
    r: u8,
    g: u8,
    b: u8,
    a: u8,
}

// These are more bytes than are needed to encode two `Pixel`s.
let bytes = &mut [0, 1, 2, 3, 4, 5, 6, 7, 8, 9][..];

let (prefix, pixels) = <[Pixel]>::mut_from_suffix_with_elems(bytes, 2).unwrap();

assert_eq!(prefix, &[0, 1]);

assert_eq!(pixels, &[
    Pixel { r: 2, g: 3, b: 4, a: 5 },
    Pixel { r: 6, g: 7, b: 8, a: 9 },
]);

prefix.fill(9);
pixels[1] = Pixel { r: 0, g: 0, b: 0, a: 0 };

assert_eq!(bytes, [9, 9, 2, 3, 4, 5, 0, 0, 0, 0]);

Since an explicit count is provided, this method supports types with zero-sized trailing slice elements. Methods such as mut_from_suffix which do not take an explicit count do not support such types.

use zerocopy::*;

#[derive(FromBytes, IntoBytes, Immutable, KnownLayout)]
#[repr(C, packed)]
struct ZSTy {
    leading_sized: [u8; 2],
    trailing_dst: [()],
}

let src = &mut [85, 85][..];
let (_, zsty) = ZSTy::mut_from_suffix_with_elems(src, 42).unwrap();
assert_eq!(zsty.trailing_dst.len(), 42);
§ Code Generation

See TryFromBytes::ref_from_suffix_with_elems.

Source

fn read_from_bytes(source: &[u8]) -> Result<Self, SizeError<&[u8], Self>>
where Self: Sized,

Reads a copy of Self from the given source.

If source.len() != size_of::<Self>(), read_from_bytes returns Err.

§Examples
use zerocopy::FromBytes;

#[derive(FromBytes)]
#[repr(C)]
struct PacketHeader {
    src_port: [u8; 2],
    dst_port: [u8; 2],
    length: [u8; 2],
    checksum: [u8; 2],
}

// These bytes encode a `PacketHeader`.
let bytes = &[0, 1, 2, 3, 4, 5, 6, 7][..];

let header = PacketHeader::read_from_bytes(bytes).unwrap();

assert_eq!(header.src_port, [0, 1]);
assert_eq!(header.dst_port, [2, 3]);
assert_eq!(header.length, [4, 5]);
assert_eq!(header.checksum, [6, 7]);
Source

fn read_from_prefix( source: &[u8], ) -> Result<(Self, &[u8]), SizeError<&[u8], Self>>
where Self: Sized,

Reads a copy of Self from the prefix of the given source.

This attempts to read a Self from the first size_of::<Self>() bytes of source, returning that Self and any remaining bytes. If source.len() < size_of::<Self>(), it returns Err.

§Examples
use zerocopy::FromBytes;

#[derive(FromBytes)]
#[repr(C)]
struct PacketHeader {
    src_port: [u8; 2],
    dst_port: [u8; 2],
    length: [u8; 2],
    checksum: [u8; 2],
}

// These are more bytes than are needed to encode a `PacketHeader`.
let bytes = &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9][..];

let (header, body) = PacketHeader::read_from_prefix(bytes).unwrap();

assert_eq!(header.src_port, [0, 1]);
assert_eq!(header.dst_port, [2, 3]);
assert_eq!(header.length, [4, 5]);
assert_eq!(header.checksum, [6, 7]);
assert_eq!(body, [8, 9]);
Source

fn read_from_suffix( source: &[u8], ) -> Result<(&[u8], Self), SizeError<&[u8], Self>>
where Self: Sized,

Reads a copy of Self from the suffix of the given source.

This attempts to read a Self from the last size_of::<Self>() bytes of source, returning that Self and any preceding bytes. If source.len() < size_of::<Self>(), it returns Err.

§Examples
use zerocopy::FromBytes;

#[derive(FromBytes)]
#[repr(C)]
struct PacketTrailer {
    frame_check_sequence: [u8; 4],
}

// These are more bytes than are needed to encode a `PacketTrailer`.
let bytes = &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9][..];

let (prefix, trailer) = PacketTrailer::read_from_suffix(bytes).unwrap();

assert_eq!(prefix, [0, 1, 2, 3, 4, 5]);
assert_eq!(trailer.frame_check_sequence, [6, 7, 8, 9]);
Source

fn read_from_io<R>(src: R) -> Result<Self, Error>
where Self: Sized, R: Read,

Reads a copy of self from an io::Read.

This is useful for interfacing with operating system byte sinks (files, sockets, etc.).

§Examples
use zerocopy::{byteorder::big_endian::*, FromBytes};
use std::fs::File;

#[derive(FromBytes)]
#[repr(C)]
struct BitmapFileHeader {
    signature: [u8; 2],
    size: U32,
    reserved: U64,
    offset: U64,
}

let mut file = File::open("image.bin").unwrap();
let header = BitmapFileHeader::read_from_io(&mut file).unwrap();

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl FromBytes for ()

Source§

impl FromBytes for Atomic<i8>

Source§

impl FromBytes for Atomic<i16>

Source§

impl FromBytes for Atomic<i32>

Source§

impl FromBytes for Atomic<i64>

Source§

impl FromBytes for Atomic<isize>

Source§

impl FromBytes for Atomic<u8>

Source§

impl FromBytes for Atomic<u16>

Source§

impl FromBytes for Atomic<u32>

Source§

impl FromBytes for Atomic<u64>

Source§

impl FromBytes for Atomic<usize>

§

impl FromBytes for BtiInfo
where u64: FromBytes,

§

impl FromBytes for HandleCountInfo
where u32: FromBytes,

§

impl FromBytes for InfoMapsTypeUnion
where zx_info_maps_mapping_t: FromBytes,

§

impl FromBytes for InfoMapsTypeUnionV1
where zx_info_maps_mapping_v1_t: FromBytes,

§

impl FromBytes for InfoMapsTypeUnionV2
where zx_info_maps_mapping_v2_t: FromBytes,

§

impl FromBytes for Koid
where u64: FromBytes,

§

impl FromBytes for MapInfo
where Name: FromBytes, usize: FromBytes, u32: FromBytes, InfoMapsTypeUnion: FromBytes,

§

impl FromBytes for MappingDetails
where VmarFlagsExtended: FromBytes, [PadByte; 4]: FromBytes, Koid: FromBytes, u64: FromBytes, usize: FromBytes,

§

impl FromBytes for MemStats
where u64: FromBytes,

§

impl FromBytes for MemStatsCompression

§

impl FromBytes for MemStatsExtended
where u64: FromBytes,

§

impl FromBytes for MemoryStall
where i64: FromBytes,

§

impl FromBytes for Name
where [u8; 32]: FromBytes,

Source§

impl FromBytes for Option<NonZero<i8>>

Source§

impl FromBytes for Option<NonZero<i16>>

Source§

impl FromBytes for Option<NonZero<i32>>

Source§

impl FromBytes for Option<NonZero<i64>>

Source§

impl FromBytes for Option<NonZero<i128>>

Source§

impl FromBytes for Option<NonZero<isize>>

Source§

impl FromBytes for Option<NonZero<u8>>

Source§

impl FromBytes for Option<NonZero<u16>>

Source§

impl FromBytes for Option<NonZero<u32>>

Source§

impl FromBytes for Option<NonZero<u64>>

Source§

impl FromBytes for Option<NonZero<u128>>

Source§

impl FromBytes for Option<NonZero<usize>>

§

impl FromBytes for PadByte
where u8: FromBytes,

§

impl FromBytes for PerCpuStats

§

impl FromBytes for ProcessHandleStats
where [u32; 64]: FromBytes,

§

impl FromBytes for ProcessInfo
where i64: FromBytes, Instant<MonotonicTimeline>: FromBytes, ProcessInfoFlags: FromBytes, [PadByte; 4]: FromBytes,

§

impl FromBytes for ProcessInfoFlags
where u32: FromBytes,

§

impl FromBytes for ResourceInfo

§

impl FromBytes for Rights
where u32: FromBytes,

§

impl FromBytes for TaskRuntimeInfo
where i64: FromBytes,

§

impl FromBytes for TaskStatsInfo

§

impl FromBytes for VmarFlags
where u32: FromBytes,

§

impl FromBytes for VmarFlagsExtended
where u32: FromBytes,

§

impl FromBytes for VmarInfo

§

impl FromBytes for VmoInfo
where Koid: FromBytes, Name: FromBytes, u64: FromBytes, usize: FromBytes, VmoInfoFlags: FromBytes, [PadByte; 4]: FromBytes, Rights: FromBytes, u32: FromBytes,

§

impl FromBytes for VmoInfoFlags
where u32: FromBytes,

Source§

impl FromBytes for __m128

Source§

impl FromBytes for __m256

Source§

impl FromBytes for __m512

Source§

impl FromBytes for __m128d

Source§

impl FromBytes for __m128i

Source§

impl FromBytes for __m256d

Source§

impl FromBytes for __m256i

Source§

impl FromBytes for __m512bh

Source§

impl FromBytes for __m512d

Source§

impl FromBytes for __m512i

Source§

impl FromBytes for f32

Source§

impl FromBytes for f64

Source§

impl FromBytes for i8

Source§

impl FromBytes for i16

Source§

impl FromBytes for i32

Source§

impl FromBytes for i64

Source§

impl FromBytes for i128

Source§

impl FromBytes for isize

§

impl FromBytes for priority_params
where i32: FromBytes, [PadByte; 20]: FromBytes,

Source§

impl FromBytes for u8

Source§

impl FromBytes for u16

Source§

impl FromBytes for u32

Source§

impl FromBytes for u64

Source§

impl FromBytes for u128

Source§

impl FromBytes for usize

§

impl FromBytes for zx_arm64_exc_data_t
where u32: FromBytes, [PadByte; 4]: FromBytes, u64: FromBytes, [PadByte; 8]: FromBytes,

§

impl FromBytes for zx_arm64_info_guest_stats_t

§

impl FromBytes for zx_clock_create_args_v1_t
where i64: FromBytes,

§

impl FromBytes for zx_clock_details_v1_t
where u64: FromBytes, i64: FromBytes, zx_clock_transformation_t: FromBytes, u32: FromBytes, [PadByte; 4]: FromBytes,

§

impl FromBytes for zx_clock_rate_t
where u32: FromBytes,

§

impl FromBytes for zx_clock_transformation_t
where i64: FromBytes, zx_clock_rate_t: FromBytes,

§

impl FromBytes for zx_clock_update_args_v1_t
where i32: FromBytes, [PadByte; 4]: FromBytes, i64: FromBytes, u64: FromBytes,

§

impl FromBytes for zx_clock_update_args_v2_t
where i32: FromBytes, [PadByte; 4]: FromBytes, i64: FromBytes, u64: FromBytes,

§

impl FromBytes for zx_cpu_perf_limit_t

§

impl FromBytes for zx_cpu_performance_info_t
where u32: FromBytes, zx_cpu_performance_scale_t: FromBytes,

§

impl FromBytes for zx_cpu_performance_scale_t
where u32: FromBytes,

§

impl FromBytes for zx_cpu_set_t
where [u64; 8]: FromBytes,

§

impl FromBytes for zx_exception_context_t
where zx_exception_header_arch_t: FromBytes, u32: FromBytes,

§

impl FromBytes for zx_exception_header_arch_t
where zx_x86_64_exc_data_t: FromBytes, zx_arm64_exc_data_t: FromBytes, zx_riscv64_exc_data_t: FromBytes,

§

impl FromBytes for zx_exception_header_t
where u32: FromBytes,

§

impl FromBytes for zx_exception_info_t
where u64: FromBytes, u32: FromBytes, [PadByte; 4]: FromBytes,

§

impl FromBytes for zx_exception_report_t
where zx_exception_header_t: FromBytes, zx_exception_context_t: FromBytes,

§

impl FromBytes for zx_exception_report_v1_t
where zx_exception_header_t: FromBytes, [u8; 24]: FromBytes,

§

impl FromBytes for zx_info_bti_t
where u64: FromBytes,

§

impl FromBytes for zx_info_cpu_stats_t

§

impl FromBytes for zx_info_handle_basic_t
where u64: FromBytes, u32: FromBytes, [PadByte; 4]: FromBytes,

§

impl FromBytes for zx_info_handle_count_t
where u32: FromBytes,

§

impl FromBytes for zx_info_handle_extended_t

§

impl FromBytes for zx_info_interrupt_t
where u32: FromBytes,

§

impl FromBytes for zx_info_iob_t
where u64: FromBytes, u32: FromBytes, [PadByte; 4]: FromBytes,

§

impl FromBytes for zx_info_job_t
where i64: FromBytes, u8: FromBytes, [PadByte; 5]: FromBytes,

§

impl FromBytes for zx_info_kmem_stats_compression_t

§

impl FromBytes for zx_info_kmem_stats_extended_t
where u64: FromBytes,

§

impl FromBytes for zx_info_kmem_stats_t
where u64: FromBytes,

§

impl FromBytes for zx_info_kmem_stats_v1_t
where u64: FromBytes,

§

impl FromBytes for zx_info_maps_mapping_t
where u32: FromBytes, [PadByte; 4]: FromBytes, u64: FromBytes, usize: FromBytes,

§

impl FromBytes for zx_info_maps_mapping_v1_t
where u32: FromBytes, [PadByte; 4]: FromBytes, u64: FromBytes, usize: FromBytes,

§

impl FromBytes for zx_info_maps_mapping_v2_t
where u32: FromBytes, [PadByte; 4]: FromBytes, u64: FromBytes, usize: FromBytes,

§

impl FromBytes for zx_info_maps_t
where [u8; 32]: FromBytes, usize: FromBytes, u32: FromBytes, [PadByte; 4]: FromBytes, InfoMapsTypeUnion: FromBytes,

§

impl FromBytes for zx_info_maps_v1_t
where [u8; 32]: FromBytes, usize: FromBytes, u32: FromBytes, [PadByte; 4]: FromBytes, InfoMapsTypeUnionV1: FromBytes,

§

impl FromBytes for zx_info_maps_v2_t
where [u8; 32]: FromBytes, usize: FromBytes, u32: FromBytes, [PadByte; 4]: FromBytes, InfoMapsTypeUnionV2: FromBytes,

§

impl FromBytes for zx_info_memory_stall_t
where i64: FromBytes,

§

impl FromBytes for zx_info_msi_t

§

impl FromBytes for zx_info_process_handle_stats_t
where [u32; 64]: FromBytes,

§

impl FromBytes for zx_info_process_t
where i64: FromBytes, u32: FromBytes, [PadByte; 4]: FromBytes,

§

impl FromBytes for zx_info_resource_t

§

impl FromBytes for zx_info_socket_t
where u32: FromBytes, [PadByte; 4]: FromBytes, usize: FromBytes,

§

impl FromBytes for zx_info_stream_t

§

impl FromBytes for zx_info_task_runtime_t
where i64: FromBytes,

§

impl FromBytes for zx_info_task_runtime_v1_t
where i64: FromBytes,

§

impl FromBytes for zx_info_task_stats_t

§

impl FromBytes for zx_info_task_stats_v1_t

§

impl FromBytes for zx_info_thread_stats_t
where i64: FromBytes, u32: FromBytes, [PadByte; 4]: FromBytes,

§

impl FromBytes for zx_info_thread_t
where u32: FromBytes, zx_cpu_set_t: FromBytes,

§

impl FromBytes for zx_info_timer_t

§

impl FromBytes for zx_info_vcpu_t
where u32: FromBytes,

§

impl FromBytes for zx_info_vmar_t

§

impl FromBytes for zx_info_vmo_t

§

impl FromBytes for zx_info_vmo_v1_t

§

impl FromBytes for zx_info_vmo_v2_t

§

impl FromBytes for zx_info_vmo_v3_t

§

impl FromBytes for zx_iob_discipline_extension_t
where zx_iob_discipline_mediated_write_ring_buffer_t: FromBytes, [PadByte; 64]: FromBytes,

§

impl FromBytes for zx_iob_discipline_mediated_write_ring_buffer_t
where u64: FromBytes, [PadByte; 56]: FromBytes,

§

impl FromBytes for zx_iob_discipline_t
where u64: FromBytes, zx_iob_discipline_extension_t: FromBytes,

§

impl FromBytes for zx_iob_region_extension_t
where zx_iob_region_private_t: FromBytes, zx_iob_region_shared_t: FromBytes, [u8; 32]: FromBytes,

§

impl FromBytes for zx_iob_region_info_t
where zx_iob_region_t: FromBytes, u64: FromBytes,

§

impl FromBytes for zx_iob_region_private_t
where u32: FromBytes, [PadByte; 28]: FromBytes,

§

impl FromBytes for zx_iob_region_shared_t
where u32: FromBytes, [PadByte; 24]: FromBytes,

§

impl FromBytes for zx_iob_region_t
where u32: FromBytes, u64: FromBytes, zx_iob_discipline_t: FromBytes, zx_iob_region_extension_t: FromBytes,

§

impl FromBytes for zx_log_record_header_t

§

impl FromBytes for zx_log_record_t
where zx_log_record_header_t: FromBytes, [u8; 216]: FromBytes,

§

impl FromBytes for zx_packet_guest_vcpu_interrupt_t
where u64: FromBytes, u8: FromBytes, [PadByte; 15]: FromBytes,

§

impl FromBytes for zx_packet_guest_vcpu_startup_t

§

impl FromBytes for zx_packet_guest_vcpu_union_t
where zx_packet_guest_vcpu_interrupt_t: FromBytes, zx_packet_guest_vcpu_startup_t: FromBytes,

§

impl FromBytes for zx_pager_vmo_stats_t
where u32: FromBytes,

§

impl FromBytes for zx_policy_basic_v1
where u32: FromBytes,

§

impl FromBytes for zx_policy_basic_v2
where u32: FromBytes,

§

impl FromBytes for zx_policy_timer_slack

§

impl FromBytes for zx_profile_info_t
where u32: FromBytes, [PadByte; 4]: FromBytes, zx_profile_info_union: FromBytes, zx_cpu_set_t: FromBytes,

§

impl FromBytes for zx_profile_info_union
where priority_params: FromBytes, zx_sched_deadline_params_t: FromBytes,

§

impl FromBytes for zx_riscv64_exc_data_t
where u64: FromBytes, [PadByte; 8]: FromBytes,

§

impl FromBytes for zx_riscv64_info_guest_stats_t

§

impl FromBytes for zx_rseq_t

§

impl FromBytes for zx_sampler_config_t

§

impl FromBytes for zx_sched_deadline_params_t
where i64: FromBytes,

§

impl FromBytes for zx_smc_parameters_t
where u32: FromBytes, [PadByte; 4]: FromBytes, u64: FromBytes, u16: FromBytes,

§

impl FromBytes for zx_smc_result_t
where u64: FromBytes,

§

impl FromBytes for zx_thread_state_general_regs_t
where u64: FromBytes,

§

impl FromBytes for zx_vcpu_io_t
where u8: FromBytes, [PadByte; 3]: FromBytes, [u8; 4]: FromBytes,

§

impl FromBytes for zx_vcpu_state_t
where u64: FromBytes,

§

impl FromBytes for zx_vmo_dirty_range_t
where u64: FromBytes,

§

impl FromBytes for zx_vmo_lock_state_t
where u64: FromBytes,

§

impl FromBytes for zx_wait_item_t
where u32: FromBytes,

§

impl FromBytes for zx_wake_source_report_entry_t

§

impl FromBytes for zx_wake_source_report_header_t

§

impl FromBytes for zx_x86_64_exc_data_t
where u64: FromBytes,

§

impl FromBytes for zx_x86_64_info_guest_stats_t

Source§

impl<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z> FromBytes for (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z)

Source§

impl<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y> FromBytes for (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y)

Source§

impl<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X> FromBytes for (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X)

Source§

impl<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W> FromBytes for (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W)

Source§

impl<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V> FromBytes for (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V)

Source§

impl<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U> FromBytes for (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U)

Source§

impl<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T> FromBytes for (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T)

Source§

impl<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S> FromBytes for (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S)

Source§

impl<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R> FromBytes for (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R)

Source§

impl<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q> FromBytes for (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q)

Source§

impl<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P> FromBytes for (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P)

Source§

impl<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O> FromBytes for (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O)

Source§

impl<A, B, C, D, E, F, G, H, I, J, K, L, M, N> FromBytes for (A, B, C, D, E, F, G, H, I, J, K, L, M, N)

Source§

impl<A, B, C, D, E, F, G, H, I, J, K, L, M> FromBytes for (A, B, C, D, E, F, G, H, I, J, K, L, M)

Source§

impl<A, B, C, D, E, F, G, H, I, J, K, L> FromBytes for (A, B, C, D, E, F, G, H, I, J, K, L)

Source§

impl<A, B, C, D, E, F, G, H, I, J, K> FromBytes for (A, B, C, D, E, F, G, H, I, J, K)

Source§

impl<A, B, C, D, E, F, G, H, I, J> FromBytes for (A, B, C, D, E, F, G, H, I, J)

Source§

impl<A, B, C, D, E, F, G, H, I> FromBytes for (A, B, C, D, E, F, G, H, I)

Source§

impl<A, B, C, D, E, F, G, H> FromBytes for (A, B, C, D, E, F, G, H)

Source§

impl<A, B, C, D, E, F, G> FromBytes for (A, B, C, D, E, F, G)

Source§

impl<A, B, C, D, E, F> FromBytes for (A, B, C, D, E, F)

Source§

impl<A, B, C, D, E> FromBytes for (A, B, C, D, E)
where A: FromBytes, B: FromBytes, C: FromBytes, D: FromBytes, E: FromBytes,

Source§

impl<A, B, C, D> FromBytes for (A, B, C, D)
where A: FromBytes, B: FromBytes, C: FromBytes, D: FromBytes,

Source§

impl<A, B, C> FromBytes for (A, B, C)
where A: FromBytes, B: FromBytes, C: FromBytes,

Source§

impl<A, B> FromBytes for (A, B)
where A: FromBytes, B: FromBytes,

Source§

impl<A> FromBytes for (A,)
where A: FromBytes,

§

impl<T, U> FromBytes for Duration<T, U>

§

impl<T, U> FromBytes for Instant<T, U>

Source§

impl<T, const N: usize> FromBytes for [T; N]
where T: FromBytes,

Source§

impl<T> FromBytes for Cell<T>
where T: FromBytes + ?Sized,

Source§

impl<T> FromBytes for ManuallyDrop<T>
where T: FromBytes + ?Sized,

Source§

impl<T> FromBytes for MaybeUninit<T>

Source§

impl<T> FromBytes for PhantomData<T>
where T: ?Sized,

§

impl<T> FromBytes for TimerInfo<T>
where T: Timeline, u32: FromBytes, Instant<T>: FromBytes, Duration<T>: FromBytes,

Source§

impl<T> FromBytes for UnsafeCell<T>
where T: FromBytes + ?Sized,

Source§

impl<T> FromBytes for Wrapping<T>
where T: FromBytes,

Source§

impl<T> FromBytes for [T]
where T: FromBytes,

Implementors§

Source§

impl<O> FromBytes for F32<O>

Source§

impl<O> FromBytes for F64<O>

Source§

impl<O> FromBytes for I16<O>

Source§

impl<O> FromBytes for I32<O>

Source§

impl<O> FromBytes for I64<O>

Source§

impl<O> FromBytes for I128<O>

Source§

impl<O> FromBytes for Isize<O>

Source§

impl<O> FromBytes for U16<O>

Source§

impl<O> FromBytes for U32<O>

Source§

impl<O> FromBytes for U64<O>

Source§

impl<O> FromBytes for U128<O>

Source§

impl<O> FromBytes for Usize<O>

Source§

impl<T> FromBytes for ReadOnly<T>
where T: FromBytes + ?Sized,

Source§

impl<T> FromBytes for Unalign<T>
where T: FromBytes,