1 use super::{AudioFormat, ChannelCount, Direction}; 2 3 /** 4 * Unspecified marker type for use everywhere 5 */ 6 pub struct Unspecified; 7 8 /** 9 * The trait for direction marker types 10 */ 11 pub trait IsDirection { 12 const DIRECTION: Direction; 13 } 14 15 /** 16 * The input direction marker 17 */ 18 pub struct Input; 19 20 impl IsDirection for Input { 21 const DIRECTION: Direction = Direction::Input; 22 } 23 24 /** 25 * The output direction marker 26 */ 27 pub struct Output; 28 29 impl IsDirection for Output { 30 const DIRECTION: Direction = Direction::Output; 31 } 32 33 /** 34 * The traint for format marker types 35 */ 36 pub trait IsFormat { 37 const FORMAT: AudioFormat; 38 } 39 40 impl IsFormat for Unspecified { 41 const FORMAT: AudioFormat = AudioFormat::Unspecified; 42 } 43 44 impl IsFormat for i16 { 45 const FORMAT: AudioFormat = AudioFormat::I16; 46 } 47 48 impl IsFormat for i32 { 49 const FORMAT: AudioFormat = AudioFormat::I32; 50 } 51 52 impl IsFormat for f32 { 53 const FORMAT: AudioFormat = AudioFormat::F32; 54 } 55 56 /** 57 * The trait for channel count marker types 58 */ 59 pub trait IsChannelCount { 60 const CHANNEL_COUNT: ChannelCount; 61 } 62 63 impl IsChannelCount for Unspecified { 64 const CHANNEL_COUNT: ChannelCount = ChannelCount::Unspecified; 65 } 66 67 /** 68 * The single mono channel configuration marker 69 */ 70 pub struct Mono; 71 72 impl IsChannelCount for Mono { 73 const CHANNEL_COUNT: ChannelCount = ChannelCount::Mono; 74 } 75 76 /** 77 * The dual stereo channels configuration marker 78 */ 79 pub struct Stereo; 80 81 impl IsChannelCount for Stereo { 82 const CHANNEL_COUNT: ChannelCount = ChannelCount::Stereo; 83 } 84 85 pub enum AltFrame<T: IsFormat> { 86 Mono(T), 87 Stereo(T, T), 88 } 89 90 /** 91 * The trait for frame type marker types 92 */ 93 pub trait IsFrameType { 94 type Type; 95 type Format: IsFormat; 96 type ChannelCount: IsChannelCount; 97 } 98 99 impl<T: IsFormat> IsFrameType for (T, Unspecified) { 100 type Type = AltFrame<T>; 101 type Format = T; 102 type ChannelCount = Unspecified; 103 } 104 105 impl<T: IsFormat> IsFrameType for (T, Mono) { 106 type Type = T; 107 type Format = T; 108 type ChannelCount = Mono; 109 } 110 111 impl<T: IsFormat> IsFrameType for (T, Stereo) { 112 type Type = (T, T); 113 type Format = T; 114 type ChannelCount = Stereo; 115 } 116