Struct agde::Message

source ·
pub struct Message { /* private fields */ }
Expand description

A message to be communicated between clients.

Contains a MessageKind, sender UUID, and message UUID.

Implementations§

source§

impl Message

source

pub fn new(inner: MessageKind, sender: Uuid, uuid: Uuid) -> Self

Creates a new message.

source

pub fn sender(&self) -> Uuid

Get the sender UUID.

source

pub fn uuid(&self) -> Uuid

Get the message UUID.

source

pub fn inner(&self) -> &MessageKind

Get the inner MessageKind.

This contains all the data of the message.

source

pub fn inner_mut(&mut self) -> &mut MessageKind

Get a mutable reference to the inner MessageKind.

This contains all the data of the message.

source

pub fn into_inner(self) -> MessageKind

Get the inner MessageKind.

This contains all the data of the message.

source

pub fn recipient(&self) -> Recipient

Get the specific recipient if the MessageKind is targeted.

Can be used to determine to send this message to only one pier or all.

source

pub fn to_bin(&self) -> Vec<u8>

Converts the message to bytes.

You can also use bincode or any other serde-based library to serialize the message.

source

pub fn from_bin(slice: &[u8]) -> Result<Self, DecodeError>

Errors

Returns an appropriate error if the deserialisation failed.

source

pub fn to_base64(&self) -> String

Converts the message to a plain text compatible encoding, namely Base64.

This is a optimised version of converting Self::to_bin() to Base64. Since I’m using readers and writers, less allocations are needed.

source

pub fn from_base64(string: &str) -> Result<Self, DecodeError>

Errors

Returns an appropriate error if the deserialisation failed. If the Base64 encoding is wrong, the error returned is bincode::error::DecodeError::OtherString which (always) starts with base64 decoding failed.

Trait Implementations§

source§

impl Clone for Message

source§

fn clone(&self) -> Message

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Message

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'de> Deserialize<'de> for Message

source§

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 PartialEq<Message> for Message

source§

fn eq(&self, other: &Message) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for Message

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl Eq for Message

source§

impl StructuralEq for Message

source§

impl StructuralPartialEq for Message

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,