Enum DataType

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

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§

Source§

impl DataType

Source

pub fn as_u8(&self) -> u8

Trait Implementations§

Source§

impl Debug for DataType

Source§

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

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

impl Display for DataType

Source§

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

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

impl From<u8> for DataType

Source§

fn from(byte: u8) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for DataType

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for DataType

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

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

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.