[][src]Enum network_audio_protocol::MessageType

pub enum MessageType {
    Null,
    Get,
    Reply,
    Error,
    Shutdown,
    Unknown,
}

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

Null

The Null variant is used to create a null, or empty message.

Get

The Get variant is used to create a message that contains a request within it.

Reply

The Reply variant is used to create a message that contains data to fufill a Get request.

Error

The Error variant is used to create a message indicating an error occurred.

Shutdown

The Shutdown variant is used to create a shutdown / termination message.

Unknown

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]

impl StructuralPartialEq for MessageType[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.