Trait flac::Sample
[−]
[src]
pub trait Sample: PartialEq + Eq + Sized + Clone + Copy + Add<Output = Self> + AddAssign + BitAnd<Self, Output = Self> + BitOr<Self, Output = Self> + Mul<Output = Self> + Shl<u32, Output = Self> + ShlAssign<u32> + Shr<u32, Output = Self> + Shr<i8, Output = Self> + Shr<i32, Output = Self> + Sub<Output = Self> { type Normal; fn size() -> usize; fn size_extended() -> usize; fn to_normal(sample: Self) -> Option<Self::Normal>; fn from_i8(sample: i8) -> Self; fn from_i16(sample: i16) -> Self; fn from_i32(sample: i32) -> Option<Self>; fn from_i32_lossy(sample: i32) -> Self; }
An abstraction trait for keeping different sized integers.
Associated Types
type Normal
The normal size for the current a Sample
.
Required Methods
fn size() -> usize
The size, in bits, for the Sample::Normal
.
fn size_extended() -> usize
The size, in bits, for the Sample
.
fn to_normal(sample: Self) -> Option<Self::Normal>
Convert the extended Sample
to the normal.
fn from_i8(sample: i8) -> Self
Convert an i8 into a Sample
.
fn from_i16(sample: i16) -> Self
Convert an i16 into a Sample
.
fn from_i32(sample: i32) -> Option<Self>
Convert an i32 into a Sample
.
With Sample
sometimes being smaller than a i32, there is a chance
for this function to return an incorrect number. So when the number is
larger of smaller than the current Sample
, it returns None
otherwise Some(sample)
.
fn from_i32_lossy(sample: i32) -> Self
Convert an i32 into a Sample
.