Trait EncodableInteger

Source
pub trait EncodableInteger:
    Copy
    + Clone
    + Sized
    + Debug
    + PartialEq
    + Eq
    + Send
    + Sync
    + WithOrWithoutSerde {
    // Required methods
    fn n(self) -> usize;
    fn write_be(self, out: impl AsMut<[u8]>) -> Result<()>;
    fn write_le(self, out: impl AsMut<[u8]>) -> Result<()>;
}
Expand description

An integer that is encodable.

Required Methods§

Source

fn n(self) -> usize

Returns the number of bytes needed to encode the integer.

Source

fn write_be(self, out: impl AsMut<[u8]>) -> Result<()>

Writes in big endian.

§Errors

Error::OutputBufferTooSmall is raised if out cannot contain the encoded integer.

Source

fn write_le(self, out: impl AsMut<[u8]>) -> Result<()>

Writes in little endian.

§Errors

Error::OutputBufferTooSmall is raised if out cannot contain the encoded integer.

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.

Implementations on Foreign Types§

Source§

impl EncodableInteger for u8

Source§

fn n(self) -> usize

Source§

fn write_be(self, out: impl AsMut<[u8]>) -> Result<()>

Source§

fn write_le(self, out: impl AsMut<[u8]>) -> Result<()>

Source§

impl EncodableInteger for u16

Source§

fn n(self) -> usize

Source§

fn write_be(self, out: impl AsMut<[u8]>) -> Result<()>

Source§

fn write_le(self, out: impl AsMut<[u8]>) -> Result<()>

Source§

impl EncodableInteger for u32

Source§

fn n(self) -> usize

Source§

fn write_be(self, out: impl AsMut<[u8]>) -> Result<()>

Source§

fn write_le(self, out: impl AsMut<[u8]>) -> Result<()>

Source§

impl EncodableInteger for u64

Source§

fn n(self) -> usize

Source§

fn write_be(self, out: impl AsMut<[u8]>) -> Result<()>

Source§

fn write_le(self, out: impl AsMut<[u8]>) -> Result<()>

Implementors§