Skip to main content

WireType

Trait WireType 

Source
pub unsafe trait WireType: Sized + Copy {
    const WIRE_SIZE: usize;
    const CANONICAL_NAME: &'static str;
}
Expand description

Marker trait for types safe to use as zero-copy wire fields.

§Safety

Implementors must guarantee:

  • align_of::<Self>() == 1
  • size_of::<Self>() == Self::WIRE_SIZE
  • All bit patterns are valid (no invalid states)
  • The type is Copy and has no drop glue

Required Associated Constants§

Source

const WIRE_SIZE: usize

Byte size of this wire type on the wire.

Source

const CANONICAL_NAME: &'static str

The canonical type name for schema/fingerprint generation.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl WireType for WireBool

Source§

const WIRE_SIZE: usize = 1

Source§

const CANONICAL_NAME: &'static str = "bool"

Source§

impl WireType for WireU16

Source§

const WIRE_SIZE: usize = 2

Source§

const CANONICAL_NAME: &'static str = "u16"

Source§

impl WireType for WireU32

Source§

const WIRE_SIZE: usize = 4

Source§

const CANONICAL_NAME: &'static str = "u32"

Source§

impl WireType for WireU64

Source§

const WIRE_SIZE: usize = 8

Source§

const CANONICAL_NAME: &'static str = "u64"

Source§

impl WireType for WireI16

Source§

const WIRE_SIZE: usize = 2

Source§

const CANONICAL_NAME: &'static str = "i16"

Source§

impl WireType for WireI32

Source§

const WIRE_SIZE: usize = 4

Source§

const CANONICAL_NAME: &'static str = "i32"

Source§

impl WireType for WireI64

Source§

const WIRE_SIZE: usize = 8

Source§

const CANONICAL_NAME: &'static str = "i64"

Source§

impl WireType for WireI128

Source§

const WIRE_SIZE: usize = 16

Source§

const CANONICAL_NAME: &'static str = "i128"

Source§

impl WireType for WireU128

Source§

const WIRE_SIZE: usize = 16

Source§

const CANONICAL_NAME: &'static str = "u128"