Skip to main content

BaseSerder

Struct BaseSerder 

Source
pub struct BaseSerder {
    pub sad: Sadder,
    /* private fields */
}
Expand description

Base implementation of the Serder trait for serializable/deserializable entities

Fields§

§sad: Sadder

Serializable attribute dictionary (key event dict)

Implementations§

Source§

impl BaseSerder

Source

pub fn from_init( raw: Option<&[u8]>, sad: Option<&Sadder>, makify: Option<bool>, smellage: Option<Smellage>, proto: Option<String>, vrsn: Option<Versionage>, kind: Option<Kinds>, ilk: Option<Ilk>, saids: Option<HashMap<&str, String>>, ) -> Result<Self, KERIError>

Source

pub fn from_sad(sad: &Sadder) -> Result<Self, KERIError>

Source

pub fn prepare_version( &self, sad: &mut Sadder, kind: Kinds, proto: String, vrsn: Versionage, ) -> Result<(), KERIError>

Prepares a Sadder by padding the version field and then calculating the correct version string This mirrors the Python makify method’s versification logic

§Arguments
  • sad - The Sadder to prepare
  • kind - The serialization format kind
  • proto - The protocol string
  • vrsn - The version information
§Returns

The updated Sadder with proper version string

Source

pub fn compare_said(&self, said: &str) -> bool

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 verify(&self) -> Result<(), KERIError>

Source

pub fn makify( &mut self, sad: &Sadder, proto: Option<String>, vrsn: Option<Versionage>, kind: Option<Kinds>, ilk: Option<Ilk>, saids: Option<HashMap<&str, String>>, ) -> Result<(), KERIError>

Makify given sad dict makes the versions string and computes the said field values and sets associated properties: raw, sad, proto, version, kind, size

Override for protocol and ilk specific saidification behavior. Especially for inceptive ilks that have more than one said field like a said derived identifier prefix.

Default prioritization: Use method parameter if not None Else use provided version string if valid Otherwise use class attribute

§Parameters
  • sad - Serializable saidified field map of message
  • proto - Optional desired protocol type str value of Protocols. If None then its extracted from sad or uses default .Proto
  • vrsn - Optional instance desired protocol version. If None then its extracted from sad or uses default .Vrsn
  • kind - Optional serialization kind string value of Serials. supported kinds are ‘json’, ‘cbor’, ‘msgpack’, ‘binary’. If None then its extracted from sad or uses default .Kind
  • ilk - Optional desired ilk packet type str value of Ilks. If None then its extracted from sad or uses default .Ilk
  • saids - Optional dict keyed by label of codes for saidive fields to override defaults given in .Fields for a given ilk. If None then use defaults

Trait Implementations§

Source§

impl Clone for BaseSerder

Source§

fn clone(&self) -> BaseSerder

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 BaseSerder

Source§

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

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

impl Default for BaseSerder

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Rawifiable for BaseSerder

Source§

fn from_raw(raw: &[u8], smellage: Option<Smellage>) -> Result<Self, KERIError>

Returns an error if verification fails or if required fields are missing

Source§

impl Serder for BaseSerder

Source§

fn pretty(&self, size: Option<usize>) -> String

Returns a pretty-printed JSON representation of the serialized data Read more
Source§

fn raw(&self) -> &[u8] ⓘ

Returns the raw bytes representation
Source§

fn sad(&self) -> Sadder

Returns a copy of the serializable attribute dictionary (saidified data)
Source§

fn genus(&self) -> &str

Returns the CESR genus code for this Serder
Source§

fn gvrsn(&self) -> &Versionage

Returns the CESR genus code table version for this Serder
Source§

fn kind(&self) -> &Kinds

Returns the serialization kind (value of Serials/Serialage)
Source§

fn proto(&self) -> &str

Returns the protocol identifier type (e.g., ‘KERI’ or ‘ACDC’)
Source§

fn vrsn(&self) -> &Versionage

Returns the protocol version for this Serder
Source§

fn size(&self) -> usize

Returns the number of bytes in the raw representation
Source§

fn said(&self) -> Option<&str>

Returns the qb64 SAID (Self-Addressing IDentifier)
Source§

fn ilk(&self) -> Option<&str>

Returns the packet type given by sad[‘t’] if any
Source§

fn as_any(&self) -> &dyn Any

Source§

fn clone_box(&self) -> Box<dyn Serder>

Source§

fn protocol(&self) -> &str

Alias for proto() - returns the protocol identifier type
Source§

fn version(&self) -> &Versionage

Alias for vrsn() - returns the protocol version
Source§

fn saidb(&self) -> Option<Vec<u8>>

Returns the qb64b (bytes) representation of the SAID
Source§

impl Verifiable for BaseSerder

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