Struct short_hex_str::ShortHexStr
source · pub struct ShortHexStr(_);
Expand description
An efficient container for formatting a byte slice as a hex-formatted string, stored on the stack.
Using ShortHexStr
instead of hex::encode
is about 3-4x faster on a recent
MBP 2019 (~48 ns/iter vs ~170 ns/iter) in an artifical micro benchmark.
Implementations§
source§impl ShortHexStr
impl ShortHexStr
pub const SOURCE_LENGTH: usize = 4usize
pub const LENGTH: usize = 8usize
sourcepub fn try_from_bytes(
src_bytes: &[u8]
) -> Result<ShortHexStr, InputTooShortError>
pub fn try_from_bytes( src_bytes: &[u8] ) -> Result<ShortHexStr, InputTooShortError>
Format a new ShortHexStr
from a byte slice.
Returns Err(InputTooShortError)
if the input byte slice length is less
than SOURCE_LENGTH
bytes.
pub fn as_str(&self) -> &str
Trait Implementations§
source§impl Clone for ShortHexStr
impl Clone for ShortHexStr
source§fn clone(&self) -> ShortHexStr
fn clone(&self) -> ShortHexStr
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for ShortHexStr
impl Debug for ShortHexStr
source§impl Display for ShortHexStr
impl Display for ShortHexStr
source§impl Hash for ShortHexStr
impl Hash for ShortHexStr
source§impl Ord for ShortHexStr
impl Ord for ShortHexStr
source§fn cmp(&self, other: &ShortHexStr) -> Ordering
fn cmp(&self, other: &ShortHexStr) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere Self: Sized,
Compares and returns the maximum of two values. Read more
source§impl PartialEq<ShortHexStr> for ShortHexStr
impl PartialEq<ShortHexStr> for ShortHexStr
source§fn eq(&self, other: &ShortHexStr) -> bool
fn eq(&self, other: &ShortHexStr) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl PartialOrd<ShortHexStr> for ShortHexStr
impl PartialOrd<ShortHexStr> for ShortHexStr
source§fn partial_cmp(&self, other: &ShortHexStr) -> Option<Ordering>
fn partial_cmp(&self, other: &ShortHexStr) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read more