pub enum Data<'s> {
Null,
Boolean(bool),
Integer(i64),
String(AtprotoStr<'s>),
Bytes(Bytes),
CidLink(Cid<'s>),
Array(Array<'s>),
Object(Object<'s>),
Blob(Blob<'s>),
}Expand description
AT Protocol data model value
Represents any valid value in the AT Protocol data model, which supports JSON and CBOR serialization with specific constraints (no floats, CID links, blobs with metadata).
This is the generic “unknown data” type used for lexicon values, extra fields captured
by #[lexicon], and IPLD data structures.
Variants§
Null
Null value
Boolean(bool)
Boolean value
Integer(i64)
Integer value (no floats in AT Protocol)
String(AtprotoStr<'s>)
String value (parsed into specific AT Protocol types when possible)
Bytes(Bytes)
Raw bytes
CidLink(Cid<'s>)
CID link reference
Array(Array<'s>)
Array of values
Object(Object<'s>)
Object/map of values
Blob(Blob<'s>)
Blob reference with metadata
Implementations§
Source§impl<'s> Data<'s>
impl<'s> Data<'s>
Sourcepub fn data_type(&self) -> DataModelType
pub fn data_type(&self) -> DataModelType
Get the data model type of this value
Sourcepub fn from_json(json: &'s Value) -> Result<Self, AtDataError>
pub fn from_json(json: &'s Value) -> Result<Self, AtDataError>
Parse a Data value from a JSON value
Sourcepub fn from_cbor(cbor: &'s Ipld) -> Result<Self, AtDataError>
pub fn from_cbor(cbor: &'s Ipld) -> Result<Self, AtDataError>
Parse a Data value from an IPLD value (CBOR)
Trait Implementations§
Source§impl<'de, 'a> Deserialize<'de> for Data<'a>where
'de: 'a,
impl<'de, 'a> Deserialize<'de> for Data<'a>where
'de: 'a,
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>,
Currently only works for self-describing formats Thankfully the supported atproto data formats are both self-describing (json and dag-cbor). TODO: see if there’s any way to make this work with Postcard.
Source§impl IntoStatic for Data<'_>
impl IntoStatic for Data<'_>
impl<'s> Eq for Data<'s>
impl<'s> StructuralPartialEq for Data<'s>
Auto Trait Implementations§
impl<'s> !Freeze for Data<'s>
impl<'s> RefUnwindSafe for Data<'s>
impl<'s> Send for Data<'s>
impl<'s> Sync for Data<'s>
impl<'s> Unpin for Data<'s>
impl<'s> UnwindSafe for Data<'s>
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,
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
key and return true if they are equal.