pub struct Tid(/* private fields */);Expand description
A TID (Timestamp Identifier) — base32-sortable, used as record keys.
TIDs encode a microsecond timestamp and a random clock ID into a 13-character base32-sortable string. They are lexicographically ordered by creation time, making them ideal for record keys in AT Protocol repositories.
Implementations§
Source§impl Tid
impl Tid
Sourcepub fn now() -> Self
pub fn now() -> Self
Generate a new TID from the current timestamp and a random clock ID.
Uses std::time::SystemTime for the timestamp and rand for the
10-bit clock ID.
Sourcepub fn parse(s: &str) -> Result<Self, RepoError>
pub fn parse(s: &str) -> Result<Self, RepoError>
Parse a TID string, validating format.
A valid TID is exactly 13 characters long, using only characters from
the base32-sortable charset (234567abcdefghijklmnopqrstuvwxyz).
§Errors
Returns RepoError::InvalidTid if the string is not a valid TID.
Sourcepub fn into_string(self) -> String
pub fn into_string(self) -> String
Consume the TID and return the inner string.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Tid
impl<'de> Deserialize<'de> for Tid
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Source§impl Ord for Tid
impl Ord for Tid
Source§impl PartialOrd for Tid
impl PartialOrd for Tid
impl Eq for Tid
impl StructuralPartialEq for Tid
Auto Trait Implementations§
impl Freeze for Tid
impl RefUnwindSafe for Tid
impl Send for Tid
impl Sync for Tid
impl Unpin for Tid
impl UnsafeUnpin for Tid
impl UnwindSafe for Tid
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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>
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>
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§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.