Skip to main content

SadValue

Enum SadValue 

Source
pub enum SadValue {
    Bool(bool),
    Number(Number),
    String(String),
    Array(Vec<SadValue>),
    Object(IndexMap<String, SadValue>),
}

Variants§

§

Bool(bool)

§

Number(Number)

§

String(String)

§

Array(Vec<SadValue>)

§

Object(IndexMap<String, SadValue>)

Implementations§

Source§

impl SadValue

Source

pub fn loads( raw: &[u8], size: Option<usize>, kind: Kinds, ) -> Result<Sadder, KERIError>

Deserializes raw bytes into a data structure based on the specified kind

§Arguments
  • raw - Raw bytes to deserialize
  • size - Number of bytes to consume for deserialization (if None, uses all bytes)
  • kind - Serialization format (JSON, MGPK, CBOR)
§Returns

A Result containing either the deserialized data or a KERIError

§Notes

JSON deserialization uses UTF-8 string conversion, while CBOR and MGPK operate directly on bytes

Source

pub fn dumps(sad: &Sadder, kind: &Kinds) -> Result<Vec<u8>, KERIError>

§Parameters:
  • sad: Optional data to serialize. If None, uses default empty data
  • kind: Serialization format (Json, Cbor, MsgPack)
  • proto: Optional protocol type
  • vrsn: Optional protocol version
§Returns:

Serialized bytes of the data

§Errors:

Returns a KERIError if serialization fails

Source

pub fn is_array(&self) -> bool

Source

pub fn is_object(&self) -> bool

Source

pub fn is_string(&self) -> bool

Source

pub fn is_number(&self) -> bool

Source

pub fn is_bool(&self) -> bool

Source

pub fn is_i64(&self) -> bool

Source

pub fn is_u64(&self) -> bool

Source

pub fn is_f64(&self) -> bool

Source

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

Source

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

Source

pub fn as_u64(&self) -> Option<u64>

Source

pub fn as_f64(&self) -> Option<f64>

Source

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

Source

pub fn as_array(&self) -> Option<&Vec<SadValue>>

Source

pub fn as_object(&self) -> Option<&IndexMap<String, SadValue>>

Source

pub fn as_array_mut(&mut self) -> Option<&mut Vec<SadValue>>

Source

pub fn as_object_mut(&mut self) -> Option<&mut IndexMap<String, SadValue>>

Source

pub fn take_array(self) -> Option<Vec<SadValue>>

Source

pub fn take_object(self) -> Option<IndexMap<String, SadValue>>

Source

pub fn take_string(self) -> Option<String>

Source

pub fn take_bool(self) -> Option<bool>

Source

pub fn take_number(self) -> Option<Number>

Source

pub fn from_bool(b: bool) -> Self

Source

pub fn from_i64(i: i64) -> Self

Source

pub fn from_u64(u: u64) -> Self

Source

pub fn from_f64(f: f64) -> Result<Self, String>

Source

pub fn from_string<S: Into<String>>(s: S) -> Self

Source

pub fn from_array<A: IntoIterator<Item = SadValue>>(a: A) -> Self

Source

pub fn from_object<O: IntoIterator<Item = (String, SadValue)>>(o: O) -> Self

Source

pub fn pointer(&self, path: &str) -> Option<&SadValue>

Source

pub fn pointer_mut(&mut self, path: &str) -> Option<&mut SadValue>

Source

pub fn get<I: Index>(&self, index: I) -> Option<&SadValue>

Source

pub fn get_mut<I: Index>(&mut self, index: I) -> Option<&mut SadValue>

Trait Implementations§

Source§

impl Clone for SadValue

Source§

fn clone(&self) -> SadValue

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 Debug for SadValue

Source§

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

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

impl<'de> Deserialize<'de> for SadValue

Source§

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 Eq for SadValue

Source§

impl PartialEq for SadValue

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl Serialize for SadValue

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

Auto Trait Implementations§

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>,

§

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

§

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

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

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

§

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.

§

impl<T> Instrument for T

§

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

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

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> 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.
§

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

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

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