[][src]Enum network_audio_protocol::DataType

pub enum DataType {
    Null,
    SampleRate,
    SampleFormat,
    ChannelCount,
    AudioSamples,
    Unknown,
}

A listing of data types used to compose Get and Reply Messages

Description

The Data Type enum variants are used to specify what data is contained in a Message, it comes directly after the Message Type, and is only relevant for MessageType::Get and MessageType::Reply Messages. Each variant as a mapping to a u8 integer.

u8 Variant Mappings

  • Null == 0
  • SampleRate == 1
  • SampleFormat == 2
  • ChannelCount == 3
  • AudioSamples == 4
  • Unknown >= 5

Examples

use network_audio_protocol::DataType;
 
// create a DataType variant from the integer 1
let data_type: DataType = DataType::from(1);

// turn the DataType variant into a string
let as_string: String = data_type.to_string();

// check for valid results
assert_eq!(DataType::SampleRate, data_type);
assert_eq!(String::from("SampleRate"), as_string);
 
// print out the DataType variant, and its u8 integer mapping
println!("Data Type: {}, maps to: {}", data_type, data_type.as_u8());

Variants

Null

Used to send a Message whithout a data type.

SampleRate

Used to send a message requesting / containing the audio sample rate or frequency. SampleRate is represented as a u32 integer.

SampleFormat

Used to send a message requesting / containing the audio data sample format. SampleFormat is represented as (bool, bool, u32) tuple, where the first boolean is the Endianness of the samples (true == Little Endian), the second boolean is the Signedness of the samples (true == Signed), and the u32 is the bit depth of the samples.

ChannelCount

Used to send a message requesting / containing the number of audio channels. ChannelCount is represented as a u32 integer.

AudioSamples

Used to send a message requesting / containing audio samples / audio data. AudioSamples are represented as a u8 slice, or &[u8]. The Endianness and Signedness of the bytes is not altered when the message is serialized / deserialized.

Unknown

Not formally used in composing messages, but rather for specifying that a message is made up of an unknown, or undefined data type.

Implementations

impl DataType[src]

pub fn as_u8(&self) -> u8[src]

Trait Implementations

impl Debug for DataType[src]

impl Display for DataType[src]

impl From<u8> for DataType[src]

impl PartialEq<DataType> for DataType[src]

impl StructuralPartialEq for DataType[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.