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.