Struct DefaultMessagePacker

Source
pub struct DefaultMessagePacker { /* private fields */ }
Expand description

Default implementation of the MessagePacker trait.

This implementation uses DIDComm for message packing and unpacking, providing secure communications with support for the different security modes defined in the TAP protocol.

Implementations§

Source§

impl DefaultMessagePacker

Source

pub fn new( did_resolver: Arc<dyn SyncDIDResolver>, secrets_resolver: Arc<dyn DebugSecretsResolver>, ) -> Self

Create a new DefaultMessagePacker

§Parameters
  • did_resolver - The DID resolver to use for resolving DIDs
  • secrets_resolver - The secrets resolver to use for cryptographic operations
Source

pub async fn unpack_message<T: DeserializeOwned + Send>( &self, packed: &str, ) -> Result<T>

Unpack a message and parse it to the requested type

Trait Implementations§

Source§

impl Debug for DefaultMessagePacker

Source§

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

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

impl MessagePacker for DefaultMessagePacker

Source§

fn pack_message<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, message: &'life1 (dyn Serialize + Sync), to: &'life2 str, from: Option<&'life3 str>, mode: SecurityMode, ) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Pack a message for the specified recipient using DIDComm

Serializes the message, creates a DIDComm message, and applies the appropriate security measures based on the security mode.

§Parameters
  • message - The message to pack
  • to - The DID of the recipient
  • from - The DID of the sender, or None for anonymous messages
  • mode - The security mode to use
§Returns

The packed message as a string

Source§

fn unpack_message_value<'life0, 'life1, 'async_trait>( &'life0 self, packed: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Unpack a DIDComm message and return its contents as JSON

Verifies signatures and decrypts content as needed based on how the message was originally packed.

§Parameters
  • packed - The packed DIDComm message
§Returns

The unpacked message content as JSON Value

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> AsAny for T
where T: 'static,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Return a reference to self as Any
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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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