pub struct Prefix { /* private fields */ }
Expand description
An partial owned hash possibly identifying an object uniquely, whose non-prefix bytes are zeroed.
Implementations
sourceimpl Prefix
impl Prefix
sourcepub fn new(id: impl AsRef<oid>, hex_len: usize) -> Result<Self, Error>
pub fn new(id: impl AsRef<oid>, hex_len: usize) -> Result<Self, Error>
Create a new instance by taking a full id
as input and truncating it to hex_len
.
For instance, with hex_len
of 7 the resulting prefix is 3.5 bytes, or 3 bytes and 4 bits
wide, with all other bytes and bits set to zero.
sourcepub fn as_oid(&self) -> &oid
pub fn as_oid(&self) -> &oid
Returns the prefix as object id.
Note that it may be deceptive to use given that it looks like a full object id, even though its post-prefix bytes/bits are set to zero.
sourcepub fn hex_len(&self) -> usize
pub fn hex_len(&self) -> usize
Return the amount of hexadecimal characters that are set in the prefix.
This gives the prefix a granularity of 4 bits.
Trait Implementations
sourceimpl<'de> Deserialize<'de> for Prefix
impl<'de> Deserialize<'de> for Prefix
sourcefn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl Ord for Prefix
impl Ord for Prefix
sourceimpl PartialOrd<Prefix> for Prefix
impl PartialOrd<Prefix> for Prefix
sourcefn partial_cmp(&self, other: &Prefix) -> Option<Ordering>
fn partial_cmp(&self, other: &Prefix) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn 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
impl Copy for Prefix
impl Eq for Prefix
impl StructuralEq for Prefix
impl StructuralPartialEq for Prefix
Auto Trait Implementations
impl RefUnwindSafe for Prefix
impl Send for Prefix
impl Sync for Prefix
impl Unpin for Prefix
impl UnwindSafe for Prefix
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more