Skip to main content

Data

Enum Data 

Source
pub enum Data<S: Bos<str> + AsRef<str> = DefaultStr> {
    Null,
    Boolean(bool),
    Integer(i64),
    String(AtprotoStr<S>),
    Bytes(Bytes),
    CidLink(Cid<S>),
    Array(Array<S>),
    Object(Object<S>),
    Blob(Blob<S>),
    InvalidNumber(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

CID link reference

§

Array(Array<S>)

Array of values

§

Object(Object<S>)

Object/map of values

§

Blob(Blob<S>)

Blob reference with metadata

§

InvalidNumber(S)

Invalid number (floating point)

Implementations§

Source§

impl<S> Data<S>
where S: Bos<str> + AsRef<str>,

Source

pub fn data_type(&self) -> DataModelType

Get the data model type of this value

Source

pub fn as_object(&self) -> Option<&Object<S>>

Get as object if this is an Object variant

Source

pub fn as_array(&self) -> Option<&Array<S>>

Get as array if this is an Array variant

Source

pub fn as_str(&self) -> Option<&str>

Get as string if this is a String variant

Source

pub fn as_object_mut<'a>(&'a mut self) -> Option<&'a mut Object<S>>

Get as object if this is an Object variant

Source

pub fn as_array_mut<'a>(&'a mut self) -> Option<&'a mut Array<S>>

Get as array if this is an Array variant

Source

pub fn as_str_mut<'s>(&'s mut self) -> Option<&'s mut AtprotoStr<S>>

Get as string if this is a String variant

Source

pub fn as_integer_mut(&mut self) -> Option<&mut i64>

Get as integer if this is an Integer variant

Source

pub fn as_boolean_mut(&mut self) -> Option<&mut bool>

Get a mutable reference to the boolean if this is a Boolean variant

Source

pub fn as_integer(&self) -> Option<i64>

Get as integer if this is an Integer variant

Source

pub fn as_boolean(&self) -> Option<bool>

Get as boolean if this is a Boolean variant

Source

pub fn is_null(&self) -> bool

Check if this is a null value

Source

pub fn type_discriminator(&self) -> Option<&str>

Get the “$type” discriminator field if this is an object with a string “$type” field

This is a shortcut for union type discrimination in AT Protocol. Returns None if this is not an object or if the “$type” field is missing/not a string.

Source

pub fn to_dag_cbor(&self) -> Result<Vec<u8>, EncodeError<TryReserveError>>
where S: Serialize,

Serialize to canonical DAG-CBOR bytes for CID computation

This produces the deterministic CBOR encoding used for content-addressing.

Source

pub fn get_at_path<'s>(&'s self, path: &str) -> Option<&'s Data<S>>

Get a value at a path within nested Data structures

Path syntax:

  • .field or field - access object field
  • [0] - access array index
  • Combined: embed.images[0].alt
§Example
let data: Data = ...;
if let Some(alt_text) = data.get_at_path("embed.images[0].alt") {
    println!("Alt text: {}", alt_text.as_str().unwrap());
}
Source

pub fn get_at_path_mut(&mut self, path: &str) -> Option<&mut Data<S>>

Get a mutable reference to a field at the given path

Uses the same path syntax as get_at_path.

Source

pub fn set_at_path(&mut self, path: &str, new_data: Data<S>) -> bool

Set the value at the given path, returning true if successful

Uses the same path syntax as get_at_path.

Source

pub fn query<'s>(&'s self, pattern: &str) -> QueryResult<'s, S>

Query data with pattern matching

Pattern syntax:

  • field.nested - exact path navigation
  • [..] - wildcard over collection (array elements or object values)
  • field..nested - scoped recursion (find nested within field, expect one)
  • ...field - global recursion (find all occurrences anywhere)
§Examples
// Exact path with wildcard
let alts = data.query("embed.[..].alt");

// Scoped recursion
let handle = data.query("post..handle"); // finds post.author.handle

// Global recursion
let all_cids = data.query("...cid"); // all CIDs anywhere
Source§

impl<S: Bos<str> + AsRef<str>> Data<S>

Source

pub fn convert<B: Bos<str> + AsRef<str> + From<S>>(self) -> Data<B>

Convert to a Data with a different backing type.

Trait Implementations§

Source§

impl<S: Clone + Bos<str> + AsRef<str>> Clone for Data<S>

Source§

fn clone(&self) -> Data<S>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<S: Debug + Bos<str> + AsRef<str>> Debug for Data<S>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de, S> Deserialize<'de> for Data<S>
where S: Bos<str> + AsRef<str> + Deserialize<'de>,

Source§

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<'de, S> Deserializer<'de> for &'de Data<S>
where S: AsRef<str> + Bos<str>,

Source§

type Error = DataDeserializerError

The error type that can be returned if some error occurs during deserialization.
Source§

fn deserialize_any<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Require the Deserializer to figure out how to drive the visitor based on what data type is in the input. Read more
Source§

fn deserialize_option<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an optional value. Read more
Source§

fn deserialize_bool<V>( self, visitor: V, ) -> Result<V::Value, <Self as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a bool value.
Source§

fn deserialize_i8<V>( self, visitor: V, ) -> Result<V::Value, <Self as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an i8 value.
Source§

fn deserialize_i16<V>( self, visitor: V, ) -> Result<V::Value, <Self as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an i16 value.
Source§

fn deserialize_i32<V>( self, visitor: V, ) -> Result<V::Value, <Self as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an i32 value.
Source§

fn deserialize_i64<V>( self, visitor: V, ) -> Result<V::Value, <Self as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an i64 value.
Source§

fn deserialize_i128<V>( self, visitor: V, ) -> Result<V::Value, <Self as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an i128 value. Read more
Source§

fn deserialize_u8<V>( self, visitor: V, ) -> Result<V::Value, <Self as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a u8 value.
Source§

fn deserialize_u16<V>( self, visitor: V, ) -> Result<V::Value, <Self as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a u16 value.
Source§

fn deserialize_u32<V>( self, visitor: V, ) -> Result<V::Value, <Self as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a u32 value.
Source§

fn deserialize_u64<V>( self, visitor: V, ) -> Result<V::Value, <Self as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a u64 value.
Source§

fn deserialize_u128<V>( self, visitor: V, ) -> Result<V::Value, <Self as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an u128 value. Read more
Source§

fn deserialize_f32<V>( self, visitor: V, ) -> Result<V::Value, <Self as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a f32 value.
Source§

fn deserialize_f64<V>( self, visitor: V, ) -> Result<V::Value, <Self as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a f64 value.
Source§

fn deserialize_char<V>( self, visitor: V, ) -> Result<V::Value, <Self as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a char value.
Source§

fn deserialize_str<V>( self, visitor: V, ) -> Result<V::Value, <Self as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a string value and does not benefit from taking ownership of buffered data owned by the Deserializer. Read more
Source§

fn deserialize_string<V>( self, visitor: V, ) -> Result<V::Value, <Self as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a string value and would benefit from taking ownership of buffered data owned by the Deserializer. Read more
Source§

fn deserialize_bytes<V>( self, visitor: V, ) -> Result<V::Value, <Self as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a byte array and does not benefit from taking ownership of buffered data owned by the Deserializer. Read more
Source§

fn deserialize_byte_buf<V>( self, visitor: V, ) -> Result<V::Value, <Self as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a byte array and would benefit from taking ownership of buffered data owned by the Deserializer. Read more
Source§

fn deserialize_unit<V>( self, visitor: V, ) -> Result<V::Value, <Self as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a unit value.
Source§

fn deserialize_unit_struct<V>( self, name: &'static str, visitor: V, ) -> Result<V::Value, <Self as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a unit struct with a particular name.
Source§

fn deserialize_newtype_struct<V>( self, name: &'static str, visitor: V, ) -> Result<V::Value, <Self as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a newtype struct with a particular name.
Source§

fn deserialize_seq<V>( self, visitor: V, ) -> Result<V::Value, <Self as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a sequence of values.
Source§

fn deserialize_tuple<V>( self, len: usize, visitor: V, ) -> Result<V::Value, <Self as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a sequence of values and knows how many values there are without looking at the serialized data.
Source§

fn deserialize_tuple_struct<V>( self, name: &'static str, len: usize, visitor: V, ) -> Result<V::Value, <Self as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a tuple struct with a particular name and number of fields.
Source§

fn deserialize_map<V>( self, visitor: V, ) -> Result<V::Value, <Self as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a map of key-value pairs.
Source§

fn deserialize_struct<V>( self, name: &'static str, fields: &'static [&'static str], visitor: V, ) -> Result<V::Value, <Self as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a struct with a particular name and fields.
Source§

fn deserialize_enum<V>( self, name: &'static str, variants: &'static [&'static str], visitor: V, ) -> Result<V::Value, <Self as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an enum value with a particular name and possible variants.
Source§

fn deserialize_identifier<V>( self, visitor: V, ) -> Result<V::Value, <Self as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting the name of a struct field or the discriminant of an enum variant.
Source§

fn deserialize_ignored_any<V>( self, visitor: V, ) -> Result<V::Value, <Self as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type needs to deserialize a value whose type doesn’t matter because it is ignored. Read more
Source§

fn is_human_readable(&self) -> bool

Determine whether Deserialize implementations should expect to deserialize their human-readable form. Read more
Source§

impl<'de, S> Deserializer<'de> for Data<S>
where S: AsRef<str> + Bos<str>,

Source§

type Error = DataDeserializerError

The error type that can be returned if some error occurs during deserialization.
Source§

fn deserialize_any<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Require the Deserializer to figure out how to drive the visitor based on what data type is in the input. Read more
Source§

fn deserialize_option<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an optional value. Read more
Source§

fn deserialize_bool<V>( self, visitor: V, ) -> Result<V::Value, <Self as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a bool value.
Source§

fn deserialize_i8<V>( self, visitor: V, ) -> Result<V::Value, <Self as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an i8 value.
Source§

fn deserialize_i16<V>( self, visitor: V, ) -> Result<V::Value, <Self as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an i16 value.
Source§

fn deserialize_i32<V>( self, visitor: V, ) -> Result<V::Value, <Self as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an i32 value.
Source§

fn deserialize_i64<V>( self, visitor: V, ) -> Result<V::Value, <Self as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an i64 value.
Source§

fn deserialize_i128<V>( self, visitor: V, ) -> Result<V::Value, <Self as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an i128 value. Read more
Source§

fn deserialize_u8<V>( self, visitor: V, ) -> Result<V::Value, <Self as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a u8 value.
Source§

fn deserialize_u16<V>( self, visitor: V, ) -> Result<V::Value, <Self as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a u16 value.
Source§

fn deserialize_u32<V>( self, visitor: V, ) -> Result<V::Value, <Self as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a u32 value.
Source§

fn deserialize_u64<V>( self, visitor: V, ) -> Result<V::Value, <Self as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a u64 value.
Source§

fn deserialize_u128<V>( self, visitor: V, ) -> Result<V::Value, <Self as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an u128 value. Read more
Source§

fn deserialize_f32<V>( self, visitor: V, ) -> Result<V::Value, <Self as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a f32 value.
Source§

fn deserialize_f64<V>( self, visitor: V, ) -> Result<V::Value, <Self as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a f64 value.
Source§

fn deserialize_char<V>( self, visitor: V, ) -> Result<V::Value, <Self as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a char value.
Source§

fn deserialize_str<V>( self, visitor: V, ) -> Result<V::Value, <Self as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a string value and does not benefit from taking ownership of buffered data owned by the Deserializer. Read more
Source§

fn deserialize_string<V>( self, visitor: V, ) -> Result<V::Value, <Self as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a string value and would benefit from taking ownership of buffered data owned by the Deserializer. Read more
Source§

fn deserialize_bytes<V>( self, visitor: V, ) -> Result<V::Value, <Self as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a byte array and does not benefit from taking ownership of buffered data owned by the Deserializer. Read more
Source§

fn deserialize_byte_buf<V>( self, visitor: V, ) -> Result<V::Value, <Self as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a byte array and would benefit from taking ownership of buffered data owned by the Deserializer. Read more
Source§

fn deserialize_unit<V>( self, visitor: V, ) -> Result<V::Value, <Self as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a unit value.
Source§

fn deserialize_unit_struct<V>( self, name: &'static str, visitor: V, ) -> Result<V::Value, <Self as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a unit struct with a particular name.
Source§

fn deserialize_newtype_struct<V>( self, name: &'static str, visitor: V, ) -> Result<V::Value, <Self as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a newtype struct with a particular name.
Source§

fn deserialize_seq<V>( self, visitor: V, ) -> Result<V::Value, <Self as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a sequence of values.
Source§

fn deserialize_tuple<V>( self, len: usize, visitor: V, ) -> Result<V::Value, <Self as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a sequence of values and knows how many values there are without looking at the serialized data.
Source§

fn deserialize_tuple_struct<V>( self, name: &'static str, len: usize, visitor: V, ) -> Result<V::Value, <Self as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a tuple struct with a particular name and number of fields.
Source§

fn deserialize_map<V>( self, visitor: V, ) -> Result<V::Value, <Self as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a map of key-value pairs.
Source§

fn deserialize_struct<V>( self, name: &'static str, fields: &'static [&'static str], visitor: V, ) -> Result<V::Value, <Self as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a struct with a particular name and fields.
Source§

fn deserialize_enum<V>( self, name: &'static str, variants: &'static [&'static str], visitor: V, ) -> Result<V::Value, <Self as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an enum value with a particular name and possible variants.
Source§

fn deserialize_identifier<V>( self, visitor: V, ) -> Result<V::Value, <Self as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting the name of a struct field or the discriminant of an enum variant.
Source§

fn deserialize_ignored_any<V>( self, visitor: V, ) -> Result<V::Value, <Self as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type needs to deserialize a value whose type doesn’t matter because it is ignored. Read more
Source§

fn is_human_readable(&self) -> bool

Determine whether Deserialize implementations should expect to deserialize their human-readable form. Read more
Source§

impl<S: Eq + Bos<str> + AsRef<str>> Eq for Data<S>

Source§

impl<'a, S> From<&'a str> for Data<S>
where S: AsRef<str> + Bos<str> + From<&'a str>,

Source§

fn from(t: &'a str) -> Self

Converts to this type from the input type.
Source§

impl<S> From<&Cid<S>> for Data<S>
where S: AsRef<str> + Bos<str> + Clone,

Source§

fn from(t: &Cid<S>) -> Self

Converts to this type from the input type.
Source§

impl<S> From<&[u8]> for Data<S>
where S: AsRef<str> + Bos<str>,

Source§

fn from(t: &[u8]) -> Self

Converts to this type from the input type.
Source§

impl<S> From<Array<S>> for Data<S>
where S: AsRef<str> + Bos<str>,

Source§

fn from(t: Array<S>) -> Self

Converts to this type from the input type.
Source§

impl<S> From<AtprotoStr<S>> for Data<S>
where S: AsRef<str> + Bos<str>,

Source§

fn from(t: AtprotoStr<S>) -> Self

Converts to this type from the input type.
Source§

impl<S> From<Blob<S>> for Data<S>
where S: AsRef<str> + Bos<str>,

Source§

fn from(t: Blob<S>) -> Self

Converts to this type from the input type.
Source§

impl<S> From<BlobRef<S>> for Data<S>
where S: AsRef<str> + Bos<str>,

Source§

fn from(t: BlobRef<S>) -> Self

Converts to this type from the input type.
Source§

impl<S> From<Box<[u8]>> for Data<S>
where S: AsRef<str> + Bos<str>,

Source§

fn from(t: Box<[u8]>) -> Self

Converts to this type from the input type.
Source§

impl<S> From<Cid<S>> for Data<S>
where S: AsRef<str> + Bos<str>,

Source§

fn from(t: Cid<S>) -> Self

Converts to this type from the input type.
Source§

impl<S> From<CidLink<S>> for Data<S>
where S: AsRef<str> + Bos<str>,

Source§

fn from(t: CidLink<S>) -> Self

Converts to this type from the input type.
Source§

impl<'s, S> From<Cow<'s, str>> for Data<S>
where S: AsRef<str> + Bos<str> + FromStr<Err = Infallible>,

Source§

fn from(t: Cow<'s, str>) -> Self

Converts to this type from the input type.
Source§

impl<'s, S> From<CowStr<'s>> for Data<S>
where S: AsRef<str> + Bos<str> + FromStr<Err = Infallible>,

Source§

fn from(t: CowStr<'s>) -> Self

Converts to this type from the input type.
Source§

impl<S> From<Object<S>> for Data<S>
where S: AsRef<str> + Bos<str>,

Source§

fn from(t: Object<S>) -> Self

Converts to this type from the input type.
Source§

impl<S> From<SmolStr> for Data<S>
where S: AsRef<str> + Bos<str> + From<SmolStr>,

Source§

fn from(t: SmolStr) -> Self

Converts to this type from the input type.
Source§

impl<S> From<String> for Data<S>
where S: AsRef<str> + Bos<str> + From<String>,

Source§

fn from(t: String) -> Self

Converts to this type from the input type.
Source§

impl<S> From<Vec<u8>> for Data<S>
where S: AsRef<str> + Bos<str>,

Source§

fn from(t: Vec<u8>) -> Self

Converts to this type from the input type.
Source§

impl<S> From<bool> for Data<S>
where S: AsRef<str> + Bos<str>,

Source§

fn from(t: bool) -> Self

Converts to this type from the input type.
Source§

impl<S> From<i8> for Data<S>
where S: AsRef<str> + Bos<str>,

Source§

fn from(t: i8) -> Self

Converts to this type from the input type.
Source§

impl<S> From<i16> for Data<S>
where S: AsRef<str> + Bos<str>,

Source§

fn from(t: i16) -> Self

Converts to this type from the input type.
Source§

impl<S> From<i32> for Data<S>
where S: AsRef<str> + Bos<str>,

Source§

fn from(t: i32) -> Self

Converts to this type from the input type.
Source§

impl<S> From<i64> for Data<S>
where S: AsRef<str> + Bos<str>,

Source§

fn from(t: i64) -> Self

Converts to this type from the input type.
Source§

impl<S> From<i128> for Data<S>
where S: AsRef<str> + Bos<str>,

Source§

fn from(t: i128) -> Self

Converts to this type from the input type.
Source§

impl<S> From<isize> for Data<S>
where S: AsRef<str> + Bos<str>,

Source§

fn from(t: isize) -> Self

Converts to this type from the input type.
Source§

impl<S> From<u8> for Data<S>
where S: AsRef<str> + Bos<str>,

Source§

fn from(t: u8) -> Self

Converts to this type from the input type.
Source§

impl<S> From<u16> for Data<S>
where S: AsRef<str> + Bos<str>,

Source§

fn from(t: u16) -> Self

Converts to this type from the input type.
Source§

impl<S> From<u32> for Data<S>
where S: AsRef<str> + Bos<str>,

Source§

fn from(t: u32) -> Self

Converts to this type from the input type.
Source§

impl<S> From<u64> for Data<S>
where S: AsRef<str> + Bos<str>,

Source§

fn from(t: u64) -> Self

Converts to this type from the input type.
Source§

impl<S> From<usize> for Data<S>
where S: AsRef<str> + Bos<str>,

Source§

fn from(t: usize) -> Self

Converts to this type from the input type.
Source§

impl<S> IntoStatic for Data<S>
where S: Bos<str> + AsRef<str> + IntoStatic, <S as IntoStatic>::Output: AsRef<str> + Bos<str>,

Source§

type Output = Data<<S as IntoStatic>::Output>

The “owned” variant of the type. For Cow<'a, str>, this is Cow<'static, str>, for example.
Source§

fn into_static(self) -> Data<<S as IntoStatic>::Output>

Turns the value into an “owned” variant, which can then be returned, moved, etc. Read more
Source§

impl<S: PartialEq + Bos<str> + AsRef<str>> PartialEq for Data<S>

Source§

fn eq(&self, other: &Data<S>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<D> Serialize for Data<D>
where D: Bos<str> + AsRef<str> + Serialize,

Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<S: Bos<str> + AsRef<str>> StructuralPartialEq for Data<S>

Source§

impl<S> TryFrom<Data<S>> for ()
where S: AsRef<str> + Bos<str>,

Source§

type Error = ConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(ipld: Data<S>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<S> TryFrom<Data<S>> for Option<String>
where S: AsRef<str> + Bos<str> + Clone + Serialize,

Source§

type Error = ConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(ipld: Data<S>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<S> TryFrom<Data<S>> for String
where S: AsRef<str> + Bos<str> + TryFrom<String> + Clone + Serialize,

Source§

type Error = ConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(ipld: Data<S>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<S> TryFrom<Data<S>> for bool
where S: AsRef<str> + Bos<str> + 'static,

Source§

type Error = ConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(ipld: Data<S>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<S> TryFrom<Data<S>> for i8
where S: AsRef<str> + Bos<str> + 'static,

Source§

type Error = ConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(ipld: Data<S>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<S> TryFrom<Data<S>> for i16
where S: AsRef<str> + Bos<str> + 'static,

Source§

type Error = ConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(ipld: Data<S>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<S> TryFrom<Data<S>> for i32
where S: AsRef<str> + Bos<str> + 'static,

Source§

type Error = ConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(ipld: Data<S>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<S> TryFrom<Data<S>> for i64
where S: AsRef<str> + Bos<str> + 'static,

Source§

type Error = ConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(ipld: Data<S>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<S> TryFrom<Data<S>> for i128
where S: AsRef<str> + Bos<str> + 'static,

Source§

type Error = ConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(ipld: Data<S>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<S> TryFrom<Data<S>> for isize
where S: AsRef<str> + Bos<str> + 'static,

Source§

type Error = ConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(ipld: Data<S>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<S> TryFrom<Data<S>> for u8
where S: AsRef<str> + Bos<str> + 'static,

Source§

type Error = ConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(ipld: Data<S>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<S> TryFrom<Data<S>> for u16
where S: AsRef<str> + Bos<str> + 'static,

Source§

type Error = ConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(ipld: Data<S>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<S> TryFrom<Data<S>> for u32
where S: AsRef<str> + Bos<str> + 'static,

Source§

type Error = ConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(ipld: Data<S>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<S> TryFrom<Data<S>> for u64
where S: AsRef<str> + Bos<str> + 'static,

Source§

type Error = ConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(ipld: Data<S>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<S> TryFrom<Data<S>> for u128
where S: AsRef<str> + Bos<str> + 'static,

Source§

type Error = ConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(ipld: Data<S>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<S> TryFrom<Data<S>> for usize
where S: AsRef<str> + Bos<str> + 'static,

Source§

type Error = ConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(ipld: Data<S>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<S> TryFrom<Data<S>> for Vec<u8>
where S: AsRef<str> + Bos<str> + 'static,

Source§

type Error = ConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(ipld: Data<S>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<S> TryFrom<Data<S>> for Array<S>
where S: AsRef<str> + Bos<str> + 'static,

Source§

type Error = ConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(ipld: Data<S>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<S> TryFrom<Data<S>> for Object<S>
where S: AsRef<str> + Bos<str> + 'static,

Source§

type Error = ConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(ipld: Data<S>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<S> TryFrom<Data<S>> for Cid<S>
where S: AsRef<str> + Bos<str> + 'static,

Source§

type Error = ConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(ipld: Data<S>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<S> TryFrom<Data<S>> for Blob<S>
where S: AsRef<str> + Bos<str> + 'static,

Source§

type Error = ConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(ipld: Data<S>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<S> TryFrom<Data<S>> for Option<bool>
where S: AsRef<str> + Bos<str> + 'static,

Source§

type Error = ConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(ipld: Data<S>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<S> TryFrom<Data<S>> for Option<i8>
where S: AsRef<str> + Bos<str> + 'static,

Source§

type Error = ConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(ipld: Data<S>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<S> TryFrom<Data<S>> for Option<i16>
where S: AsRef<str> + Bos<str> + 'static,

Source§

type Error = ConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(ipld: Data<S>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<S> TryFrom<Data<S>> for Option<i32>
where S: AsRef<str> + Bos<str> + 'static,

Source§

type Error = ConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(ipld: Data<S>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<S> TryFrom<Data<S>> for Option<i64>
where S: AsRef<str> + Bos<str> + 'static,

Source§

type Error = ConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(ipld: Data<S>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<S> TryFrom<Data<S>> for Option<i128>
where S: AsRef<str> + Bos<str> + 'static,

Source§

type Error = ConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(ipld: Data<S>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<S> TryFrom<Data<S>> for Option<isize>
where S: AsRef<str> + Bos<str> + 'static,

Source§

type Error = ConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(ipld: Data<S>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<S> TryFrom<Data<S>> for Option<u8>
where S: AsRef<str> + Bos<str> + 'static,

Source§

type Error = ConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(ipld: Data<S>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<S> TryFrom<Data<S>> for Option<u16>
where S: AsRef<str> + Bos<str> + 'static,

Source§

type Error = ConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(ipld: Data<S>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<S> TryFrom<Data<S>> for Option<u32>
where S: AsRef<str> + Bos<str> + 'static,

Source§

type Error = ConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(ipld: Data<S>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<S> TryFrom<Data<S>> for Option<u64>
where S: AsRef<str> + Bos<str> + 'static,

Source§

type Error = ConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(ipld: Data<S>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<S> TryFrom<Data<S>> for Option<u128>
where S: AsRef<str> + Bos<str> + 'static,

Source§

type Error = ConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(ipld: Data<S>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<S> TryFrom<Data<S>> for Option<usize>
where S: AsRef<str> + Bos<str> + 'static,

Source§

type Error = ConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(ipld: Data<S>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<S> TryFrom<Data<S>> for Option<Vec<u8>>
where S: AsRef<str> + Bos<str> + 'static,

Source§

type Error = ConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(ipld: Data<S>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<S> TryFrom<Data<S>> for Option<Array<S>>
where S: AsRef<str> + Bos<str> + 'static,

Source§

type Error = ConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(ipld: Data<S>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<S> TryFrom<Data<S>> for Option<Object<S>>
where S: AsRef<str> + Bos<str> + 'static,

Source§

type Error = ConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(ipld: Data<S>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<S> TryFrom<Data<S>> for Option<Cid<S>>
where S: AsRef<str> + Bos<str> + 'static,

Source§

type Error = ConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(ipld: Data<S>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<S> TryFrom<Data<S>> for Option<Blob<S>>
where S: AsRef<str> + Bos<str> + 'static,

Source§

type Error = ConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(ipld: Data<S>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'s, S> TryFrom<RawData<'s>> for Data<S>
where S: Bos<str> + AsRef<str> + From<CowStr<'s>>,

Convert RawData to validated Data with type inference

Source§

type Error = ConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(raw: RawData<'s>) -> Result<Self, Self::Error>

Performs the conversion.

Auto Trait Implementations§

§

impl<S = SmolStr> !Freeze for Data<S>

§

impl<S> RefUnwindSafe for Data<S>
where S: RefUnwindSafe,

§

impl<S> Send for Data<S>
where S: Send,

§

impl<S> Sync for Data<S>
where S: Sync,

§

impl<S> Unpin for Data<S>
where S: Unpin,

§

impl<S> UnsafeUnpin for Data<S>
where S: UnsafeUnpin,

§

impl<S> UnwindSafe for Data<S>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more