pub struct Uid { /* private fields */ }Expand description
Each chunk, image and file has uid.
Uid is a 256 bit hash value, generated by sha3-256 hash function and some postprocessing.
The most convenient way for users to deal with uid is using uid_query function. The user
inputs a hex representation of a uid, or a prefix of it, and the function returns
matched uids.
The first 192 bits (128 of high + 64 of low) are from the hash function, and
the remaining bits are for metadata.
Implementations§
Source§impl Uid
impl Uid
pub fn decode(bytes: &[u8]) -> Result<Self, Error>
pub fn encode(&self, buffer: &mut Vec<u8>)
pub fn new_chunk(chunk: &Chunk) -> Self
pub fn new_image(bytes: &[u8]) -> Self
pub fn new_file(root_dir: &str, path: &str) -> Result<Self, Error>
pub fn new_group(uids: &[Uid]) -> Self
pub fn new_knowledge_base(uids: &[Uid]) -> Self
pub fn new_summary(summary: &str) -> Self
pub fn new_query_turn(turn: &QueryTurn) -> Self
pub fn update_file_uid(old: Uid, old_path: &str, new_path: &str) -> Self
pub fn get_prefix(&self) -> String
pub fn get_suffix(&self) -> String
Sourcepub fn abbrev(&self, n: usize) -> String
pub fn abbrev(&self, n: usize) -> String
It returns the first n characters of the uid.
It returns the full uid if n is greater than or equal to 64.
pub fn is_valid_prefix(s: &str) -> bool
Trait Implementations§
Source§impl AddAssign for Uid
impl AddAssign for Uid
Source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
Performs the
+= operation. Read moreSource§impl BitXorAssign for Uid
impl BitXorAssign for Uid
Source§fn bitxor_assign(&mut self, rhs: Self)
fn bitxor_assign(&mut self, rhs: Self)
Performs the
^= operation. Read moreSource§impl<'de> Deserialize<'de> for Uid
impl<'de> Deserialize<'de> for Uid
Source§fn 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
Source§impl Ord for Uid
impl Ord for Uid
Source§impl PartialOrd for Uid
impl PartialOrd for Uid
impl Copy for Uid
impl Eq for Uid
impl StructuralPartialEq for Uid
Auto Trait Implementations§
impl Freeze for Uid
impl RefUnwindSafe for Uid
impl Send for Uid
impl Sync for Uid
impl Unpin for Uid
impl UnwindSafe for Uid
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> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
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<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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.