pub struct AtprotoRecord { /* private fields */ }Expand description
A generic public AT Protocol repository record.
The value is retained as a typed DAG-CBOR value and its exact public bytes
and CID are derived once at construction. This is deliberately independent
of native ModelRecord: any supported collection can be stored without
converting through a lossy JSON DTO. Construction validates the collection,
general record key, $type discriminator and canonical public bytes; it does
not grant write authority or perform a full Lexicon validation.
Implementations§
Source§impl AtprotoRecord
impl AtprotoRecord
pub fn new( collection: impl Into<String>, rkey: impl Into<AtprotoRecordKey>, value: DagCbor, ) -> Result<Self>
Sourcepub fn from_bytes(
collection: impl Into<String>,
rkey: impl Into<AtprotoRecordKey>,
bytes: &[u8],
) -> Result<Self>
pub fn from_bytes( collection: impl Into<String>, rkey: impl Into<AtprotoRecordKey>, bytes: &[u8], ) -> Result<Self>
Reconstruct a record only when bytes are already strict public canonical encoding. This check prevents a caller from changing the CID by normalizing at a later boundary.
pub fn bytes(&self) -> &[u8] ⓘ
Sourcepub fn collection(&self) -> &str
pub fn collection(&self) -> &str
The validated collection NSID. Record identity fields are immutable
after construction so this always agrees with bytes() and cid().
Sourcepub fn rkey(&self) -> &AtprotoRecordKey
pub fn rkey(&self) -> &AtprotoRecordKey
The validated record key.
pub fn cid(&self) -> Cid
pub fn uri(&self, did: &str) -> String
Trait Implementations§
Source§impl Clone for AtprotoRecord
impl Clone for AtprotoRecord
Source§fn clone(&self) -> AtprotoRecord
fn clone(&self) -> AtprotoRecord
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for AtprotoRecord
impl Debug for AtprotoRecord
Source§impl PartialEq for AtprotoRecord
impl PartialEq for AtprotoRecord
Source§fn eq(&self, other: &AtprotoRecord) -> bool
fn eq(&self, other: &AtprotoRecord) -> bool
self and other values to be equal, and is used by ==.impl StructuralPartialEq for AtprotoRecord
Auto Trait Implementations§
impl Freeze for AtprotoRecord
impl RefUnwindSafe for AtprotoRecord
impl Send for AtprotoRecord
impl Sync for AtprotoRecord
impl Unpin for AtprotoRecord
impl UnsafeUnpin for AtprotoRecord
impl UnwindSafe for AtprotoRecord
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<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