pub struct HexPrefix { /* private fields */ }
Expand description
An identifier prefix (typically from a type implementing the ObjectId
trait) with facilities for converting between bytes and a hex string.
Implementations§
Source§impl HexPrefix
impl HexPrefix
Sourcepub fn try_from_hex(prefix: &str) -> Option<HexPrefix>
pub fn try_from_hex(prefix: &str) -> Option<HexPrefix>
Returns a new HexPrefix
or None
if prefix
cannot be decoded from
hex to bytes.
Sourcepub fn try_from_reverse_hex(prefix: &str) -> Option<HexPrefix>
pub fn try_from_reverse_hex(prefix: &str) -> Option<HexPrefix>
Returns a new HexPrefix
or None
if prefix
cannot be decoded from
“reverse” hex to bytes.
pub fn from_bytes(bytes: &[u8]) -> Self
Sourcepub fn from_id<T: ObjectId + ?Sized>(id: &T) -> Self
pub fn from_id<T: ObjectId + ?Sized>(id: &T) -> Self
Returns a new HexPrefix
representing the given id
.
Sourcepub fn reverse_hex(&self) -> String
pub fn reverse_hex(&self) -> String
Returns string representation of this prefix using z-k
“digits”.
Sourcepub fn min_prefix_bytes(&self) -> &[u8] ⓘ
pub fn min_prefix_bytes(&self) -> &[u8] ⓘ
Minimum bytes that would match this prefix. (e.g. “abc0” for “abc”)
Use this to partition a sorted slice, and test matches(id)
from there.
Sourcepub fn as_full_bytes(&self) -> Option<&[u8]>
pub fn as_full_bytes(&self) -> Option<&[u8]>
Returns the bytes representation if this prefix can be a full id.
Trait Implementations§
impl Eq for HexPrefix
impl StructuralPartialEq for HexPrefix
Auto Trait Implementations§
impl Freeze for HexPrefix
impl RefUnwindSafe for HexPrefix
impl Send for HexPrefix
impl Sync for HexPrefix
impl Unpin for HexPrefix
impl UnwindSafe for HexPrefix
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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