pub struct SerializedMessage {
serialized_message_bytes: Vec<u8>,
content_type: CoapContentFormat,
}Expand description
A message (struct) to be signed, serialized to a byte array, along with the content format of the bytes.
Fields§
§serialized_message_bytes: Vec<u8>§content_type: CoapContentFormatImplementations§
Source§impl SerializedMessage
impl SerializedMessage
Sourcepub fn from_bytes(bytes: Vec<u8>, content_type: CoapContentFormat) -> Self
pub fn from_bytes(bytes: Vec<u8>, content_type: CoapContentFormat) -> Self
Creates a new SerializedMessage from a byte array and content type.
Sourcepub fn as_bytes(&self) -> &[u8] ⓘ
pub fn as_bytes(&self) -> &[u8] ⓘ
Returns the serialized message bytes as a slice. This representation needs to be used together with a content type to deserialize the message correctly.
pub(crate) fn content_type(&self) -> CoapContentFormat
Sourcepub(crate) fn encode<Message: Serialize>(
message: &Message,
) -> Result<Self, EncodingError>
pub(crate) fn encode<Message: Serialize>( message: &Message, ) -> Result<Self, EncodingError>
Encodes a message into a SerializedMessage using CBOR serialization.
Sourcepub fn decode<Message: DeserializeOwned>(
&self,
) -> Result<Message, EncodingError>
pub fn decode<Message: DeserializeOwned>( &self, ) -> Result<Message, EncodingError>
Creates a new SerializedMessage from a byte array and content type.
This currently implements only CBOR serialization, so the content type must be Cbor.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SerializedMessage
impl RefUnwindSafe for SerializedMessage
impl Send for SerializedMessage
impl Sync for SerializedMessage
impl Unpin for SerializedMessage
impl UnwindSafe for SerializedMessage
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
§impl<T> CompatExt for T
impl<T> CompatExt for T
§impl<T, UT> HandleAlloc<UT> for T
impl<T, UT> HandleAlloc<UT> for T
§fn new_handle(value: Arc<T>) -> Handle
fn new_handle(value: Arc<T>) -> Handle
Create a new handle for an Arc value Read more
§unsafe fn clone_handle(handle: Handle) -> Handle
unsafe fn clone_handle(handle: Handle) -> Handle
Clone a handle Read more
§unsafe fn consume_handle(handle: Handle) -> Arc<T>
unsafe fn consume_handle(handle: Handle) -> Arc<T>
Consume a handle, getting back the initial
Arc<> Read moreSource§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§impl<Ctx, T> MeasureWith<Ctx> for T
impl<Ctx, T> MeasureWith<Ctx> for T
§fn measure_with(&self, _ctx: &Ctx) -> usize
fn measure_with(&self, _ctx: &Ctx) -> usize
How large is
Self, given the ctx?