[−][src]Enum network_audio_protocol::MessageType
A listing of all the different kinds of message types that a Message can be composed of.
Description
The Message Type variants are put at the beginning of a network message, and determine what kind of message the network message will be. Each variant of the MessageType enum maps to a u8 integer, a MessageType variant can also be created from a u8 integer.
u8 Variant Mappings
Null == 0
Get == 1
Reply == 2
Error == 3
Shutdown == 4
Unknown >= 5
Examples
use network_audio_protocol::MessageType; let message_type: MessageType = MessageType::from(1); assert_eq!(message_type, MessageType::Get); assert_eq!(message_type.to_string(), String::from("Get")); println!("Message Type: {}, maps to: {}", message_type, message_type.as_u8());
The above code creates a MessageType
variant from the u8 integer 1
, confirms that it is
equal to MessageType::Get
, turns the MessageType
into a String
, and compares it to
another string value, and finally prints the MessageType
and its corresponding u8 value
Variants
The Null
variant is used to create a null, or empty message.
The Get
variant is used to create a message that contains a request within it.
The Reply
variant is used to create a message that contains data to fufill a Get
request.
The Error
variant is used to create a message indicating an error occurred.
The Shutdown
variant is used to create a shutdown / termination message.
The Unkown
variant is not used to make any messages, but rather to represent a message of
an unknown type.
Implementations
impl MessageType
[src]
pub fn as_u8(&self) -> u8
[src]
Returns the corresponding u8 integer value for the used MessageType
variant. Unlike
Into
it does not consume self.
Trait Implementations
impl Debug for MessageType
[src]
impl Display for MessageType
[src]
impl From<u8> for MessageType
[src]
impl PartialEq<MessageType> for MessageType
[src]
fn eq(&self, other: &MessageType) -> bool
[src]
#[must_use]fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl StructuralPartialEq for MessageType
[src]
Auto Trait Implementations
impl RefUnwindSafe for MessageType
impl Send for MessageType
impl Sync for MessageType
impl Unpin for MessageType
impl UnwindSafe for MessageType
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,