pub struct PlainMessage<T = Value> {Show 13 fields
pub id: String,
pub typ: String,
pub type_: String,
pub body: T,
pub from: String,
pub to: Vec<String>,
pub thid: Option<String>,
pub pthid: Option<String>,
pub extra_headers: HashMap<String, Value>,
pub created_time: Option<u64>,
pub expires_time: Option<u64>,
pub from_prior: Option<String>,
pub attachments: Option<Vec<Attachment>>,
}Expand description
Wrapper for plain message. Provides helpers for message building and packing/unpacking. Adapted from https://github.com/sicpa-dlab/didcomm-rust/blob/main/src/message/message.rs
Fields§
§id: StringMessage id. Must be unique to the sender.
typ: StringOptional, if present it must be “application/didcomm-plain+json”
type_: StringMessage type attribute value MUST be a valid Message Type URI, that when resolved gives human readable information about the message. The attribute’s value also informs the content of the message, or example the presence of other attributes and how they should be processed.
body: TMessage body - strongly typed when T is specified.
from: StringSender identifier. The from attribute MUST be a string that is a valid DID or DID URL (without the fragment component) which identifies the sender of the message.
to: Vec<String>Identifier(s) for recipients. MUST be an array of strings where each element is a valid DID or DID URL (without the fragment component) that identifies a member of the message’s intended audience.
thid: Option<String>Uniquely identifies the thread that the message belongs to.
If not included the id property of the message MUST be treated as the value of the thid.
pthid: Option<String>If the message is a child of a thread the pthid
will uniquely identify which thread is the parent.
extra_headers: HashMap<String, Value>Custom message headers.
created_time: Option<u64>The attribute is used for the sender to express when they created the message, expressed in UTC Epoch Seconds (seconds since 1970-01-01T00:00:00Z UTC). This attribute is informative to the recipient, and may be relied on by protocols.
expires_time: Option<u64>The expires_time attribute is used for the sender to express when they consider the message to be expired, expressed in UTC Epoch Seconds (seconds since 1970-01-01T00:00:00Z UTC). This attribute signals when the message is considered no longer valid by the sender. When omitted, the message is considered to have no expiration by the sender.
from_prior: Option<String>from_prior is a compactly serialized signed JWT containing FromPrior value
attachments: Option<Vec<Attachment>>Implementations§
Source§impl<T> PlainMessage<T>where
T: Serialize + DeserializeOwned,
impl<T> PlainMessage<T>where
T: Serialize + DeserializeOwned,
Sourcepub fn new(id: String, type_: String, body: T, from: String) -> PlainMessage<T>
pub fn new(id: String, type_: String, body: T, from: String) -> PlainMessage<T>
Create a new PlainMessage with the given body
Sourcepub fn with_recipients(self, to: Vec<String>) -> PlainMessage<T>
pub fn with_recipients(self, to: Vec<String>) -> PlainMessage<T>
Builder method to set recipients
Sourcepub fn with_recipient(self, recipient: &str) -> PlainMessage<T>
pub fn with_recipient(self, recipient: &str) -> PlainMessage<T>
Builder method to add a single recipient
Sourcepub fn with_thread_id(self, thid: Option<String>) -> PlainMessage<T>
pub fn with_thread_id(self, thid: Option<String>) -> PlainMessage<T>
Builder method to set thread ID
Sourcepub fn with_parent_thread_id(self, pthid: Option<String>) -> PlainMessage<T>
pub fn with_parent_thread_id(self, pthid: Option<String>) -> PlainMessage<T>
Builder method to set parent thread ID
Sourcepub fn with_expires_at(self, expires_time: u64) -> PlainMessage<T>
pub fn with_expires_at(self, expires_time: u64) -> PlainMessage<T>
Builder method to set expiration time
Sourcepub fn with_attachments(self, attachments: Vec<Attachment>) -> PlainMessage<T>
pub fn with_attachments(self, attachments: Vec<Attachment>) -> PlainMessage<T>
Builder method to add attachments
Sourcepub fn with_header(self, key: String, value: Value) -> PlainMessage<T>
pub fn with_header(self, key: String, value: Value) -> PlainMessage<T>
Builder method to add a custom header
Source§impl<T> PlainMessage<T>
impl<T> PlainMessage<T>
Sourcepub fn new_typed(body: T, from: &str) -> PlainMessage<T>
pub fn new_typed(body: T, from: &str) -> PlainMessage<T>
Create a new typed message
Sourcepub fn to_plain_message(self) -> Result<PlainMessage, Error>
pub fn to_plain_message(self) -> Result<PlainMessage, Error>
Convert to untyped PlainMessage for serialization/transport
Sourcepub fn extract_participants(&self) -> Vec<String>
pub fn extract_participants(&self) -> Vec<String>
Extract recipients based on the message body participants
Source§impl<T> PlainMessage<T>
impl<T> PlainMessage<T>
Sourcepub fn extract_participants_with_context(&self) -> Vec<String>
pub fn extract_participants_with_context(&self) -> Vec<String>
Extract participants using MessageContext
Sourcepub fn new_typed_with_context(body: T, from: &str) -> PlainMessage<T>
pub fn new_typed_with_context(body: T, from: &str) -> PlainMessage<T>
Create a typed message with automatic recipient detection
Sourcepub fn routing_hints(&self) -> RoutingHints
pub fn routing_hints(&self) -> RoutingHints
Get routing hints from the message body
Sourcepub fn transaction_context(&self) -> Option<TransactionContext>
pub fn transaction_context(&self) -> Option<TransactionContext>
Get transaction context from the message body
Source§impl PlainMessage
impl PlainMessage
Sourcepub fn from_untyped(plain_msg: PlainMessage) -> PlainMessage
pub fn from_untyped(plain_msg: PlainMessage) -> PlainMessage
Create a typed message from an untyped PlainMessage
Sourcepub fn parse_body<T>(self) -> Result<PlainMessage<T>, Error>where
T: TapMessageBody,
pub fn parse_body<T>(self) -> Result<PlainMessage<T>, Error>where
T: TapMessageBody,
Try to parse the body into a specific TAP message type
Sourcepub fn parse_tap_message(&self) -> Result<TapMessage, Error>
pub fn parse_tap_message(&self) -> Result<TapMessage, Error>
Parse into the TapMessage enum for runtime dispatch
Trait Implementations§
Source§impl<T> Clone for PlainMessage<T>where
T: Clone,
impl<T> Clone for PlainMessage<T>where
T: Clone,
Source§fn clone(&self) -> PlainMessage<T>
fn clone(&self) -> PlainMessage<T>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Connectable for PlainMessage
impl Connectable for PlainMessage
Source§fn with_connection(&mut self, connection_id: &str) -> &mut PlainMessage
fn with_connection(&mut self, connection_id: &str) -> &mut PlainMessage
Source§fn has_connection(&self) -> bool
fn has_connection(&self) -> bool
Source§impl<T> Debug for PlainMessage<T>where
T: Debug,
impl<T> Debug for PlainMessage<T>where
T: Debug,
Source§impl<'de, T> Deserialize<'de> for PlainMessage<T>where
T: Serialize + DeserializeOwned,
impl<'de, T> Deserialize<'de> for PlainMessage<T>where
T: Serialize + DeserializeOwned,
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<PlainMessage<T>, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<PlainMessage<T>, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Packable for PlainMessage
Implement Packable for PlainMessage
impl Packable for PlainMessage
Implement Packable for PlainMessage
Source§fn pack<'life0, 'life1, 'async_trait>(
&'life0 self,
key_manager: &'life1 (impl 'async_trait + KeyManagerPacking + ?Sized),
options: PackOptions,
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn pack<'life0, 'life1, 'async_trait>(
&'life0 self,
key_manager: &'life1 (impl 'async_trait + KeyManagerPacking + ?Sized),
options: PackOptions,
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§impl<T> PartialEq for PlainMessage<T>where
T: PartialEq,
impl<T> PartialEq for PlainMessage<T>where
T: PartialEq,
Source§impl PlainMessageExt<Value> for PlainMessage
impl PlainMessageExt<Value> for PlainMessage
Source§fn into_typed(self) -> PlainMessage
fn into_typed(self) -> PlainMessage
Source§fn parse_as<U>(self) -> Result<PlainMessage<U>, Error>where
U: TapMessageBody,
fn parse_as<U>(self) -> Result<PlainMessage<U>, Error>where
U: TapMessageBody,
Source§impl<T> Serialize for PlainMessage<T>where
T: Serialize + DeserializeOwned,
impl<T> Serialize for PlainMessage<T>where
T: Serialize + DeserializeOwned,
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Source§impl TapMessage for PlainMessage
impl TapMessage for PlainMessage
Source§fn is_tap_message(&self) -> bool
fn is_tap_message(&self) -> bool
Source§fn get_tap_type(&self) -> Option<String>
fn get_tap_type(&self) -> Option<String>
Source§fn body_as<T>(&self) -> Result<T, Error>where
T: TapMessageBody,
fn body_as<T>(&self) -> Result<T, Error>where
T: TapMessageBody,
Source§fn get_all_participants(&self) -> Vec<String>
fn get_all_participants(&self) -> Vec<String>
Source§fn parent_thread_id(&self) -> Option<&str>
fn parent_thread_id(&self) -> Option<&str>
Source§fn message_id(&self) -> &str
fn message_id(&self) -> &str
Source§fn create_reply<T>(
&self,
body: &T,
creator_did: &str,
) -> Result<PlainMessage, Error>where
T: TapMessageBody,
fn create_reply<T>(
&self,
body: &T,
creator_did: &str,
) -> Result<PlainMessage, Error>where
T: TapMessageBody,
impl<T> Eq for PlainMessage<T>where
T: Eq,
impl<T> StructuralPartialEq for PlainMessage<T>
Auto Trait Implementations§
impl<T> Freeze for PlainMessage<T>where
T: Freeze,
impl<T> RefUnwindSafe for PlainMessage<T>where
T: RefUnwindSafe,
impl<T> Send for PlainMessage<T>where
T: Send,
impl<T> Sync for PlainMessage<T>where
T: Sync,
impl<T> Unpin for PlainMessage<T>where
T: Unpin,
impl<T> UnsafeUnpin for PlainMessage<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for PlainMessage<T>where
T: UnwindSafe,
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.