pub struct GtpMessage {
pub message_id: u64,
pub sender_id: u32,
pub timestamp_ms: u64,
pub request_id: u32,
pub flags: u8,
pub content_type: u8,
pub content_length: u32,
pub content: ByteBuf,
}Expand description
GTP message envelope. Eight CBOR keys.
Fields§
§message_id: u64Message identifier (used for idempotency).
sender_id: u32Sender member identifier.
timestamp_ms: u64Send timestamp in milliseconds since the Unix epoch.
request_id: u32Request identifier (echoed in ACK / NACK).
flags: u8Message flag bits (urgent / ephemeral / persistent).
content_type: u8content_type (see GtpContentType).
content_length: u32Declared length of content.
content: ByteBufBody bytes.
Implementations§
Source§impl GtpMessage
impl GtpMessage
Sourcepub fn plain(sender_id: u32, message_id: u64, text: &str) -> GtpMessage
pub fn plain(sender_id: u32, message_id: u64, text: &str) -> GtpMessage
Builds a plaintext (UTF-8) message.
Sourcepub fn from_cbor(data: &[u8]) -> Result<GtpMessage, CodecError>
pub fn from_cbor(data: &[u8]) -> Result<GtpMessage, CodecError>
Decodes a CBOR-encoded message and validates content_length.
Sourcepub fn to_bytes(&self, codec: PayloadCodec) -> Vec<u8> ⓘ
pub fn to_bytes(&self, codec: PayloadCodec) -> Vec<u8> ⓘ
Encodes the message using the given codec.
Sourcepub fn from_bytes(
data: &[u8],
codec: PayloadCodec,
) -> Result<GtpMessage, CodecError>
pub fn from_bytes( data: &[u8], codec: PayloadCodec, ) -> Result<GtpMessage, CodecError>
Decodes a message from the given codec.
Trait Implementations§
Source§impl Clone for GtpMessage
impl Clone for GtpMessage
Source§fn clone(&self) -> GtpMessage
fn clone(&self) -> GtpMessage
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · 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 GtpMessage
impl Debug for GtpMessage
Source§impl<'de> Deserialize<'de> for GtpMessage
impl<'de> Deserialize<'de> for GtpMessage
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<GtpMessage, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<GtpMessage, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Serialize for GtpMessage
impl Serialize for GtpMessage
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,
Serialize this value into the given Serde serializer. Read more
Source§impl TryFrom<GtpMessage> for GtpMessage
impl TryFrom<GtpMessage> for GtpMessage
Source§impl<'a> TryFrom<GtpMessageRef<'a>> for GtpMessage
impl<'a> TryFrom<GtpMessageRef<'a>> for GtpMessage
Auto Trait Implementations§
impl Freeze for GtpMessage
impl RefUnwindSafe for GtpMessage
impl Send for GtpMessage
impl Sync for GtpMessage
impl Unpin for GtpMessage
impl UnsafeUnpin for GtpMessage
impl UnwindSafe for GtpMessage
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> Declassify for T
impl<T> Declassify for T
type Declassified = T
fn declassify(self) -> T
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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