#[repr(u8)]pub enum Encoding {
Lowercase = 0,
Uppercase = 1,
}Expand description
Character set for hex encoding (uppercase or lowercase).
Variants§
Implementations§
Source§impl Encoding
impl Encoding
Sourcepub const fn encode_nibble(self, nibble: u8) -> u8
pub const fn encode_nibble(self, nibble: u8) -> u8
Converts a nibble (0-15) to a hex character using branchless arithmetic.
§Examples
use omp_core::hex::{LOWER, UPPER};
assert_eq!(LOWER.encode_nibble(10), b'a');
assert_eq!(UPPER.encode_nibble(15), b'F');Sourcepub const fn encode_mut(self, src: &[u8], dst: &mut [u8]) -> usize
pub const fn encode_mut(self, src: &[u8], dst: &mut [u8]) -> usize
Encodes bytes to hex into a flat byte buffer.
Writes ASCII hex characters to dst and returns the number of bytes
written. The output length is min(dst.len(), 2 * src.len()).
§Examples
use omp_core::hex;
let mut buf = [0u8; 10];
let n = hex::LOWER.encode_mut(b"Hello", &mut buf);
assert_eq!(n, 10);
assert_eq!(&buf, b"48656c6c6f");Sourcepub const fn encode_byte(self, byte: u8) -> [u8; 2]
pub const fn encode_byte(self, byte: u8) -> [u8; 2]
Encodes a single byte to a hex pair.
§Examples
use omp_core::hex::{LOWER, UPPER};
assert_eq!(LOWER.encode_byte(0x48), *b"48");
assert_eq!(UPPER.encode_byte(0xff), *b"FF");Trait Implementations§
impl Copy for Encoding
impl Eq for Encoding
Source§impl Ord for Encoding
impl Ord for Encoding
1.21.0 (const: unstable) · 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 PartialOrd for Encoding
impl PartialOrd for Encoding
impl StructuralPartialEq for Encoding
Auto Trait Implementations§
impl Freeze for Encoding
impl RefUnwindSafe for Encoding
impl Send for Encoding
impl Sync for Encoding
impl Unpin for Encoding
impl UnsafeUnpin for Encoding
impl UnwindSafe for Encoding
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more