Trait ToBytes

Source
pub trait ToBytes {
    const OPTIONS: ToBytesOptions = _;
Show 32 methods // Provided methods fn try_to_be_bytes(&self) -> Result<Vec<u8>> where Self: Serialize { ... } fn try_to_le_bytes(&self) -> Result<Vec<u8>> where Self: Serialize { ... } fn try_to_ne_bytes(&self) -> Result<Vec<u8>> where Self: Serialize { ... } fn try_to_be_bytes_into(&self, writer: impl Write) -> Result<()> where Self: Serialize { ... } fn try_to_le_bytes_into(&self, writer: impl Write) -> Result<()> where Self: Serialize { ... } fn try_to_ne_bytes_into(&self, writer: impl Write) -> Result<()> where Self: Serialize { ... } fn to_be_bytes(&self) -> Vec<u8> where Self: Serialize { ... } fn to_le_bytes(&self) -> Vec<u8> where Self: Serialize { ... } fn to_ne_bytes(&self) -> Vec<u8> where Self: Serialize { ... } fn to_be_bytes_into(&self, writer: impl Write) where Self: Serialize { ... } fn to_le_bytes_into(&self, writer: impl Write) where Self: Serialize { ... } fn to_ne_bytes_into(&self, writer: impl Write) where Self: Serialize { ... } fn try_from_be_bytes(bytes: impl AsBytes) -> Result<Self> where Self: DeserializeOwned { ... } fn try_from_le_bytes(bytes: impl AsBytes) -> Result<Self> where Self: DeserializeOwned { ... } fn try_from_ne_bytes(bytes: impl AsBytes) -> Result<Self> where Self: DeserializeOwned { ... } fn try_from_be_bytes_from(reader: impl Read) -> Result<Self> where Self: DeserializeOwned { ... } fn try_from_le_bytes_from(reader: impl Read) -> Result<Self> where Self: DeserializeOwned { ... } fn try_from_ne_bytes_from(reader: impl Read) -> Result<Self> where Self: DeserializeOwned { ... } fn from_be_bytes(bytes: impl AsBytes) -> Self where Self: DeserializeOwned { ... } fn from_le_bytes(bytes: impl AsBytes) -> Self where Self: DeserializeOwned { ... } fn from_ne_bytes(bytes: impl AsBytes) -> Self where Self: DeserializeOwned { ... } fn from_be_bytes_from(reader: impl Read) -> Self where Self: DeserializeOwned { ... } fn from_le_bytes_from(reader: impl Read) -> Self where Self: DeserializeOwned { ... } fn from_ne_bytes_from(reader: impl Read) -> Self where Self: DeserializeOwned { ... } fn try_to_bytes(&self) -> Result<Vec<u8>> where Self: Serialize { ... } fn try_to_bytes_into(&self, writer: impl Write) -> Result<()> where Self: Serialize { ... } fn try_from_bytes(bytes: impl AsBytes) -> Result<Self> where Self: DeserializeOwned { ... } fn try_from_bytes_from(reader: impl Read) -> Result<Self> where Self: DeserializeOwned { ... } fn to_bytes(&self) -> Vec<u8> where Self: Serialize { ... } fn to_bytes_into(&self, writer: impl Write) where Self: Serialize { ... } fn from_bytes(bytes: impl AsBytes) -> Self where Self: DeserializeOwned { ... } fn from_bytes_from(reader: impl Read) -> Self where Self: DeserializeOwned { ... }
}
Expand description

§A trait that can de/serialize something with bytes. (default: little endian)

Provided Associated Constants§

Provided Methods§

Source

fn try_to_be_bytes(&self) -> Result<Vec<u8>>
where Self: Serialize,

Serialize to bytes.

Source

fn try_to_le_bytes(&self) -> Result<Vec<u8>>
where Self: Serialize,

Source

fn try_to_ne_bytes(&self) -> Result<Vec<u8>>
where Self: Serialize,

Source

fn try_to_be_bytes_into(&self, writer: impl Write) -> Result<()>
where Self: Serialize,

Source

fn try_to_le_bytes_into(&self, writer: impl Write) -> Result<()>
where Self: Serialize,

Source

fn try_to_ne_bytes_into(&self, writer: impl Write) -> Result<()>
where Self: Serialize,

Source

fn to_be_bytes(&self) -> Vec<u8>
where Self: Serialize,

Source

fn to_le_bytes(&self) -> Vec<u8>
where Self: Serialize,

Source

fn to_ne_bytes(&self) -> Vec<u8>
where Self: Serialize,

Source

fn to_be_bytes_into(&self, writer: impl Write)
where Self: Serialize,

Source

fn to_le_bytes_into(&self, writer: impl Write)
where Self: Serialize,

Source

fn to_ne_bytes_into(&self, writer: impl Write)
where Self: Serialize,

Source

fn try_from_be_bytes(bytes: impl AsBytes) -> Result<Self>
where Self: DeserializeOwned,

Deserialize from bytes.

Source

fn try_from_le_bytes(bytes: impl AsBytes) -> Result<Self>
where Self: DeserializeOwned,

Source

fn try_from_ne_bytes(bytes: impl AsBytes) -> Result<Self>
where Self: DeserializeOwned,

Source

fn try_from_be_bytes_from(reader: impl Read) -> Result<Self>
where Self: DeserializeOwned,

Source

fn try_from_le_bytes_from(reader: impl Read) -> Result<Self>
where Self: DeserializeOwned,

Source

fn try_from_ne_bytes_from(reader: impl Read) -> Result<Self>
where Self: DeserializeOwned,

Source

fn from_be_bytes(bytes: impl AsBytes) -> Self
where Self: DeserializeOwned,

Source

fn from_le_bytes(bytes: impl AsBytes) -> Self
where Self: DeserializeOwned,

Source

fn from_ne_bytes(bytes: impl AsBytes) -> Self
where Self: DeserializeOwned,

Source

fn from_be_bytes_from(reader: impl Read) -> Self
where Self: DeserializeOwned,

Source

fn from_le_bytes_from(reader: impl Read) -> Self
where Self: DeserializeOwned,

Source

fn from_ne_bytes_from(reader: impl Read) -> Self
where Self: DeserializeOwned,

Source

fn try_to_bytes(&self) -> Result<Vec<u8>>
where Self: Serialize,

Source

fn try_to_bytes_into(&self, writer: impl Write) -> Result<()>
where Self: Serialize,

Source

fn try_from_bytes(bytes: impl AsBytes) -> Result<Self>
where Self: DeserializeOwned,

Source

fn try_from_bytes_from(reader: impl Read) -> Result<Self>
where Self: DeserializeOwned,

Source

fn to_bytes(&self) -> Vec<u8>
where Self: Serialize,

Source

fn to_bytes_into(&self, writer: impl Write)
where Self: Serialize,

Source

fn from_bytes(bytes: impl AsBytes) -> Self
where Self: DeserializeOwned,

Source

fn from_bytes_from(reader: impl Read) -> Self
where Self: DeserializeOwned,

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§