pub struct BitCounter<N, E: Endianness> { /* private fields */ }
Expand description
For counting the number of bits written but generating no output.
§Example
use tokio_bitstream_io::{BigEndian, BitWrite, BitCounter};
let mut writer: BitCounter<u32, BigEndian> = BitCounter::new();
writer.write(1, 0b1).await.unwrap();
writer.write(2, 0b01).await.unwrap();
writer.write(5, 0b10111).await.unwrap();
assert_eq!(writer.written(), 8);
Implementations§
Source§impl<N: Default + Copy, E: Endianness> BitCounter<N, E>
impl<N: Default + Copy, E: Endianness> BitCounter<N, E>
Trait Implementations§
Source§impl<N, E> BitWrite for BitCounter<N, E>
impl<N, E> BitWrite for BitCounter<N, E>
Source§fn write_bit<'life0, 'async_trait>(
&'life0 mut self,
_bit: bool,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn write_bit<'life0, 'async_trait>(
&'life0 mut self,
_bit: bool,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn write<'life0, 'async_trait, U>(
&'life0 mut self,
bits: u32,
value: U,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
U: Numeric + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
fn write<'life0, 'async_trait, U>(
&'life0 mut self,
bits: u32,
value: U,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
U: Numeric + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
Writes an unsigned value to the stream using the given
number of bits. Read more
Source§fn write_signed<'life0, 'async_trait, S>(
&'life0 mut self,
bits: u32,
value: S,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
S: SignedNumeric + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
fn write_signed<'life0, 'async_trait, S>(
&'life0 mut self,
bits: u32,
value: S,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
S: SignedNumeric + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
Writes a twos-complement signed value to the stream
with the given number of bits. Read more
Source§fn write_unary1<'life0, 'async_trait>(
&'life0 mut self,
value: u32,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn write_unary1<'life0, 'async_trait>(
&'life0 mut self,
value: u32,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Writes
value
number of 0 bits to the stream
and then writes a 1 bit. This field is variably-sized. Read moreSource§fn write_unary0<'life0, 'async_trait>(
&'life0 mut self,
value: u32,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn write_unary0<'life0, 'async_trait>(
&'life0 mut self,
value: u32,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Writes
value
number of 1 bits to the stream
and then writes a 0 bit. This field is variably-sized. Read moreSource§fn write_bytes<'life0, 'life1, 'async_trait>(
&'life0 mut self,
buf: &'life1 [u8],
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn write_bytes<'life0, 'life1, 'async_trait>(
&'life0 mut self,
buf: &'life1 [u8],
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Writes the entirety of a byte buffer to the stream. Read more
Source§fn byte_aligned(&self) -> bool
fn byte_aligned(&self) -> bool
Returns true if the stream is aligned at a whole byte.
Source§impl<N: Default, E: Default + Endianness> Default for BitCounter<N, E>
impl<N: Default, E: Default + Endianness> Default for BitCounter<N, E>
Source§fn default() -> BitCounter<N, E>
fn default() -> BitCounter<N, E>
Returns the “default value” for a type. Read more
Source§impl<N, E> HuffmanWrite<E> for BitCounter<N, E>
impl<N, E> HuffmanWrite<E> for BitCounter<N, E>
Auto Trait Implementations§
impl<N, E> Freeze for BitCounter<N, E>where
N: Freeze,
impl<N, E> RefUnwindSafe for BitCounter<N, E>where
N: RefUnwindSafe,
E: RefUnwindSafe,
impl<N, E> Send for BitCounter<N, E>where
N: Send,
impl<N, E> Sync for BitCounter<N, E>where
N: Sync,
impl<N, E> Unpin for BitCounter<N, E>
impl<N, E> UnwindSafe for BitCounter<N, E>where
N: UnwindSafe,
E: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more