pub struct BasicMessage {
pub content: String,
pub locale: Option<String>,
pub sent_time: Option<u64>,
pub metadata: HashMap<String, Value>,
}Expand description
Basic Message for simple text communication between agents
The Basic Message protocol allows agents to send simple text messages to each other. This is useful for human-readable communication and debugging purposes.
Fields§
§content: StringThe content of the message
locale: Option<String>Optional locale for the message content (e.g., “en”, “es”, “fr”)
sent_time: Option<u64>Optional timestamp when the message was sent
metadata: HashMap<String, Value>Additional metadata
Implementations§
Source§impl BasicMessage
impl BasicMessage
Sourcepub fn with_locale(content: String, locale: String) -> Self
pub fn with_locale(content: String, locale: String) -> Self
Create a Basic Message with content and locale
Sourcepub fn with_metadata(self, key: String, value: Value) -> Self
pub fn with_metadata(self, key: String, value: Value) -> Self
Add metadata
Sourcepub fn get_content(&self) -> &str
pub fn get_content(&self) -> &str
Get the content of the message
Sourcepub fn get_locale(&self) -> Option<&str>
pub fn get_locale(&self) -> Option<&str>
Get the locale of the message
Sourcepub fn get_sent_time(&self) -> Option<u64>
pub fn get_sent_time(&self) -> Option<u64>
Get the sent time
Source§impl BasicMessage
impl BasicMessage
Sourcepub fn validate_basicmessage(&self) -> Result<()>
pub fn validate_basicmessage(&self) -> Result<()>
Custom validation for Basic Message
Trait Implementations§
Source§impl Clone for BasicMessage
impl Clone for BasicMessage
Source§fn clone(&self) -> BasicMessage
fn clone(&self) -> BasicMessage
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for BasicMessage
impl Debug for BasicMessage
Source§impl<'de> Deserialize<'de> for BasicMessage
impl<'de> Deserialize<'de> for BasicMessage
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
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 MessageContext for BasicMessage
impl MessageContext for BasicMessage
Source§fn participant_dids(&self) -> Vec<String>
fn participant_dids(&self) -> Vec<String>
Extract all participant DIDs from the message
This replaces the old participants() method and works with Agent/Party types directly
Source§fn transaction_context(&self) -> Option<TransactionContext>
fn transaction_context(&self) -> Option<TransactionContext>
Get transaction context if applicable
Source§fn routing_hints(&self) -> RoutingHints
fn routing_hints(&self) -> RoutingHints
Get routing hints for message delivery
Source§fn transaction_id(&self) -> Option<String>
fn transaction_id(&self) -> Option<String>
Get transaction ID if available
Source§impl Serialize for BasicMessage
impl Serialize for BasicMessage
Source§impl TapMessage for BasicMessage
impl TapMessage for BasicMessage
Source§fn is_tap_message(&self) -> bool
fn is_tap_message(&self) -> bool
Checks if this message is a TAP message.
Source§fn get_tap_type(&self) -> Option<String>
fn get_tap_type(&self) -> Option<String>
Gets the TAP message type from this message.
Source§fn body_as<T: TapMessageBody>(&self) -> Result<T>
fn body_as<T: TapMessageBody>(&self) -> Result<T>
Extract a specific message body type from this message. Read more
Source§fn get_all_participants(&self) -> Vec<String>
fn get_all_participants(&self) -> Vec<String>
Get all participant DIDs from this message. Read more
Source§fn create_reply<T: TapMessageBody>(
&self,
body: &T,
creator_did: &str,
) -> Result<PlainMessage>
fn create_reply<T: TapMessageBody>( &self, body: &T, creator_did: &str, ) -> Result<PlainMessage>
Create a reply to this message. Read more
Source§fn parent_thread_id(&self) -> Option<&str>
fn parent_thread_id(&self) -> Option<&str>
Get the parent thread ID for this message
Source§fn message_id(&self) -> &str
fn message_id(&self) -> &str
Get the message ID for this message
Source§impl TapMessageBody for BasicMessage
impl TapMessageBody for BasicMessage
Source§fn message_type() -> &'static str
fn message_type() -> &'static str
Get the message type string for this body type.
Source§fn to_didcomm(&self, from_did: &str) -> Result<PlainMessage>
fn to_didcomm(&self, from_did: &str) -> Result<PlainMessage>
Convert this body to a DIDComm message.
Source§fn to_didcomm_with_route<'a, I>(
&self,
from: &str,
to: I,
) -> Result<PlainMessage>where
I: IntoIterator<Item = &'a str>,
fn to_didcomm_with_route<'a, I>(
&self,
from: &str,
to: I,
) -> Result<PlainMessage>where
I: IntoIterator<Item = &'a str>,
Convert this body to a DIDComm message with a custom routing path. Read more
Source§fn from_didcomm(message: &PlainMessage) -> Result<Self>where
Self: Sized,
fn from_didcomm(message: &PlainMessage) -> Result<Self>where
Self: Sized,
Extract this body type from a DIDComm message.
Auto Trait Implementations§
impl Freeze for BasicMessage
impl RefUnwindSafe for BasicMessage
impl Send for BasicMessage
impl Sync for BasicMessage
impl Unpin for BasicMessage
impl UnwindSafe for BasicMessage
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
Mutably borrows from an owned value. Read more