Trait AbstractBits

Source
pub trait AbstractBits {
    const MIN_BITS: usize;
    const MAX_BITS: usize;

    // Required methods
    fn write_abstract_bits(
        &self,
        writer: &mut BitWriter<'_>,
    ) -> Result<(), ToBytesError>;
    fn read_abstract_bits(
        reader: &mut BitReader<'_>,
    ) -> Result<Self, FromBytesError>
       where Self: Sized;

    // Provided methods
    fn to_abstract_bits(&self) -> Result<Vec<u8>, ToBytesError> { ... }
    fn from_abstract_bits(bytes: &[u8]) -> Result<Self, FromBytesError>
       where Self: Sized { ... }
}

Required Associated Constants§

Required Methods§

Source

fn write_abstract_bits( &self, writer: &mut BitWriter<'_>, ) -> Result<(), ToBytesError>

To get the amount written use BitWriter::bits_written or BitWriter::bytes_written

Source

fn read_abstract_bits( reader: &mut BitReader<'_>, ) -> Result<Self, FromBytesError>
where Self: Sized,

To get the amount read use BitReader::bits_read or BitReader::bytes_read

Provided Methods§

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 AbstractBits for bool

Source§

const MIN_BITS: usize = 1usize

Source§

const MAX_BITS: usize = 1usize

Source§

fn write_abstract_bits( &self, writer: &mut BitWriter<'_>, ) -> Result<(), ToBytesError>

Source§

fn read_abstract_bits( reader: &mut BitReader<'_>, ) -> Result<Self, FromBytesError>
where Self: Sized,

Source§

impl AbstractBits for u8

Source§

const MIN_BITS: usize = 8usize

Source§

const MAX_BITS: usize = 8usize

Source§

fn write_abstract_bits( &self, writer: &mut BitWriter<'_>, ) -> Result<(), ToBytesError>

Source§

fn read_abstract_bits( reader: &mut BitReader<'_>, ) -> Result<Self, FromBytesError>
where Self: Sized,

Source§

impl AbstractBits for u16

Source§

const MIN_BITS: usize = 16usize

Source§

const MAX_BITS: usize = 16usize

Source§

fn write_abstract_bits( &self, writer: &mut BitWriter<'_>, ) -> Result<(), ToBytesError>

Source§

fn read_abstract_bits( reader: &mut BitReader<'_>, ) -> Result<Self, FromBytesError>
where Self: Sized,

Source§

impl AbstractBits for u32

Source§

const MIN_BITS: usize = 32usize

Source§

const MAX_BITS: usize = 32usize

Source§

fn write_abstract_bits( &self, writer: &mut BitWriter<'_>, ) -> Result<(), ToBytesError>

Source§

fn read_abstract_bits( reader: &mut BitReader<'_>, ) -> Result<Self, FromBytesError>
where Self: Sized,

Source§

impl AbstractBits for u64

Source§

const MIN_BITS: usize = 64usize

Source§

const MAX_BITS: usize = 64usize

Source§

fn write_abstract_bits( &self, writer: &mut BitWriter<'_>, ) -> Result<(), ToBytesError>

Source§

fn read_abstract_bits( reader: &mut BitReader<'_>, ) -> Result<Self, FromBytesError>
where Self: Sized,

Source§

impl<const N: usize> AbstractBits for UInt<u8, N>

Source§

const MIN_BITS: usize = Self::BITS

Source§

const MAX_BITS: usize = Self::BITS

Source§

fn write_abstract_bits( &self, writer: &mut BitWriter<'_>, ) -> Result<(), ToBytesError>

Source§

fn read_abstract_bits( reader: &mut BitReader<'_>, ) -> Result<Self, FromBytesError>
where Self: Sized,

Source§

impl<const N: usize> AbstractBits for UInt<u16, N>

Source§

const MIN_BITS: usize = Self::BITS

Source§

const MAX_BITS: usize = Self::BITS

Source§

fn write_abstract_bits( &self, writer: &mut BitWriter<'_>, ) -> Result<(), ToBytesError>

Source§

fn read_abstract_bits( reader: &mut BitReader<'_>, ) -> Result<Self, FromBytesError>
where Self: Sized,

Source§

impl<const N: usize> AbstractBits for UInt<u32, N>

Source§

const MIN_BITS: usize = Self::BITS

Source§

const MAX_BITS: usize = Self::BITS

Source§

fn write_abstract_bits( &self, writer: &mut BitWriter<'_>, ) -> Result<(), ToBytesError>

Source§

fn read_abstract_bits( reader: &mut BitReader<'_>, ) -> Result<Self, FromBytesError>
where Self: Sized,

Source§

impl<const N: usize> AbstractBits for UInt<u64, N>

Source§

const MIN_BITS: usize = Self::BITS

Source§

const MAX_BITS: usize = Self::BITS

Source§

fn write_abstract_bits( &self, writer: &mut BitWriter<'_>, ) -> Result<(), ToBytesError>

Source§

fn read_abstract_bits( reader: &mut BitReader<'_>, ) -> Result<Self, FromBytesError>
where Self: Sized,

Source§

impl<const N: usize, T: AbstractBits + Sized> AbstractBits for [T; N]

Source§

const MIN_BITS: usize

Source§

const MAX_BITS: usize

Source§

fn write_abstract_bits( &self, writer: &mut BitWriter<'_>, ) -> Result<(), ToBytesError>

Source§

fn read_abstract_bits( reader: &mut BitReader<'_>, ) -> Result<Self, FromBytesError>
where Self: Sized,

Implementors§