Struct BufEncoder
pub struct BufEncoder<const CAP: usize> { /* private fields */ }
Expand description
Hex-encodes bytes into the provided buffer.
This is an important building block for fast hex-encoding. Because string writing tools
provided by core::fmt
involve dynamic dispatch and don’t allow reserving capacity in strings
buffering the hex and then formatting it is significantly faster.
Implementations§
§impl<const CAP: usize> BufEncoder<CAP>
impl<const CAP: usize> BufEncoder<CAP>
pub fn new() -> BufEncoder<CAP>
pub fn new() -> BufEncoder<CAP>
Creates an empty BufEncoder
.
pub fn put_byte(&mut self, byte: u8, case: Case)
pub fn put_byte(&mut self, byte: u8, case: Case)
Encodes byte
as hex in given case
and appends it to the buffer.
§Panics
The method panics if the buffer is full.
pub fn put_bytes<I>(&mut self, bytes: I, case: Case)
pub fn put_bytes<I>(&mut self, bytes: I, case: Case)
Encodes bytes
as hex in given case
and appends them to the buffer.
§Panics
The method panics if the bytes wouldn’t fit the buffer.
pub fn put_bytes_min<'a>(&mut self, bytes: &'a [u8], case: Case) -> &'a [u8] ⓘ
pub fn put_bytes_min<'a>(&mut self, bytes: &'a [u8], case: Case) -> &'a [u8] ⓘ
Encodes as many bytes
as fit into the buffer as hex and return the remainder.
This method works just like put_bytes
but instead of panicking it returns the unwritten
bytes. The method returns an empty slice if all bytes were written
pub fn clear(&mut self)
pub fn clear(&mut self)
Resets the buffer to become empty.
pub fn space_remaining(&self) -> usize
pub fn space_remaining(&self) -> usize
How many bytes can be written to this buffer.
Note that this returns the number of bytes before encoding, not number of hex digits.
Trait Implementations§
§impl<const CAP: usize> Default for BufEncoder<CAP>
impl<const CAP: usize> Default for BufEncoder<CAP>
§fn default() -> BufEncoder<CAP>
fn default() -> BufEncoder<CAP>
Auto Trait Implementations§
impl<const CAP: usize> Freeze for BufEncoder<CAP>
impl<const CAP: usize> RefUnwindSafe for BufEncoder<CAP>
impl<const CAP: usize> Send for BufEncoder<CAP>
impl<const CAP: usize> Sync for BufEncoder<CAP>
impl<const CAP: usize> Unpin for BufEncoder<CAP>
impl<const CAP: usize> UnwindSafe for BufEncoder<CAP>
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request