pub struct Message {
pub msg_type: MessageType,
pub session_id: Option<String>,
pub payload: Option<MessagePayload>,
pub timestamp: u64,
}Expand description
Protocol message envelope
Fields§
§msg_type: MessageTypeMessage type
session_id: Option<String>Session ID (empty for HELLO)
payload: Option<MessagePayload>Message payload
timestamp: u64Timestamp (Unix millis)
Implementations§
Source§impl Message
impl Message
Sourcepub fn hello(capabilities: Capabilities) -> Self
pub fn hello(capabilities: Capabilities) -> Self
Create a HELLO message
Sourcepub fn accept(session_id: &str, capabilities: Capabilities) -> Self
pub fn accept(session_id: &str, capabilities: Capabilities) -> Self
Create an ACCEPT message
Sourcepub fn reject(code: RejectionCode, message: &str) -> Self
pub fn reject(code: RejectionCode, message: &str) -> Self
Create a REJECT message
Sourcepub fn data(session_id: &str, algorithm: Algorithm, content: String) -> Self
pub fn data(session_id: &str, algorithm: Algorithm, content: String) -> Self
Create a DATA message
Sourcepub fn data_with_security(
session_id: &str,
algorithm: Algorithm,
content: String,
security: SecurityStatus,
) -> Self
pub fn data_with_security( session_id: &str, algorithm: Algorithm, content: String, security: SecurityStatus, ) -> Self
Create a DATA message with security status
Sourcepub fn to_json_compact(&self) -> Result<String, Error>
pub fn to_json_compact(&self) -> Result<String, Error>
Serialize to JSON (compact)
Sourcepub fn get_capabilities(&self) -> Option<&Capabilities>
pub fn get_capabilities(&self) -> Option<&Capabilities>
Get capabilities from HELLO/ACCEPT payload
Sourcepub fn get_rejection(&self) -> Option<&RejectionInfo>
pub fn get_rejection(&self) -> Option<&RejectionInfo>
Get rejection info
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Message
impl<'de> Deserialize<'de> for Message
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
Auto Trait Implementations§
impl Freeze for Message
impl RefUnwindSafe for Message
impl Send for Message
impl Sync for Message
impl Unpin for Message
impl UnwindSafe for Message
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more