ByteableRegular

Trait ByteableRegular 

Source
pub trait ByteableRegular: Sized {
    type Raw: Byteable;

    // Required methods
    fn to_raw(self) -> Self::Raw;
    fn from_raw(raw: Self::Raw) -> Self;
}
Expand description

Trait for types that can be represented in a raw byteable form.

This trait allows types to specify an associated raw type that implements Byteable, providing conversion methods between the regular type and its raw representation.

By implementing this trait, your type automatically gains a Byteable implementation that delegates to the raw type’s implementation.

§Example

This is useful for types that need preprocessing before serialization, such as converting between different representations (e.g., IPv4 addresses as u32 vs [u8; 4]).

Required Associated Types§

Source

type Raw: Byteable

The raw byteable type that represents this type in serialized form.

Required Methods§

Source

fn to_raw(self) -> Self::Raw

Converts this type to its raw representation.

Source

fn from_raw(raw: Self::Raw) -> Self

Constructs this type from its raw representation.

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§