Struct u24

Source
#[repr(C)]
pub struct u24(pub u8, pub u8, pub u8);
Expand description
  • The tuple struct is little-endian

Tuple Fields§

§0: u8§1: u8§2: u8

Implementations§

Source§

impl u24

Source

pub const MAX: u24

Source

pub const MIN: u24

Source

pub fn from_le_bytes(bytes: [u8; 3]) -> u24

Source

pub fn from_be_bytes(bytes: [u8; 3]) -> u24

Source

pub fn to_le_bytes(self) -> [u8; 3]

Source

pub fn to_be_bytes(self) -> [u8; 3]

Source

pub fn as_i128(self) -> i128

Source

pub fn as_i64(self) -> i64

Source

pub fn as_i32(self) -> i32

Source

pub fn as_i16(self) -> i16

Source

pub fn as_i8(self) -> i8

Source

pub fn as_u128(self) -> u128

Source

pub fn as_u64(self) -> u64

Source

pub fn as_u32(self) -> u32

Source

pub fn as_u16(self) -> u16

Source

pub fn as_u8(self) -> u8

Source

pub fn as_f32(self) -> f32

Source

pub fn as_f64(self) -> f64

Source

pub fn clamp(self, min: u24, max: u24) -> u24

Trait Implementations§

Source§

impl Add for u24

Source§

type Output = u24

The resulting type after applying the + operator.
Source§

fn add(self, rhs: u24) -> <u24 as Add>::Output

Performs the + operation. Read more
Source§

impl AddAssign for u24

Source§

fn add_assign(&mut self, rhs: u24)

Performs the += operation. Read more
Source§

impl BitAnd for u24

Source§

type Output = u24

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: u24) -> <u24 as BitAnd>::Output

Performs the & operation. Read more
Source§

impl BitAndAssign for u24

Source§

fn bitand_assign(&mut self, rhs: u24)

Performs the &= operation. Read more
Source§

impl BitOr for u24

Source§

type Output = u24

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: u24) -> <u24 as BitOr>::Output

Performs the | operation. Read more
Source§

impl BitOrAssign for u24

Source§

fn bitor_assign(&mut self, rhs: u24)

Performs the |= operation. Read more
Source§

impl BitXor for u24

Source§

type Output = u24

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: u24) -> <u24 as BitXor>::Output

Performs the ^ operation. Read more
Source§

impl BitXorAssign for u24

Source§

fn bitxor_assign(&mut self, rhs: u24)

Performs the ^= operation. Read more
Source§

impl Clone for u24

Source§

fn clone(&self) -> u24

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for u24

Source§

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

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

impl Default for u24

Source§

fn default() -> u24

Returns the “default value” for a type. Read more
Source§

impl Display for u24

Source§

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

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

impl Div for u24

Source§

type Output = u24

The resulting type after applying the / operator.
Source§

fn div(self, rhs: u24) -> <u24 as Div>::Output

Performs the / operation. Read more
Source§

impl DivAssign for u24

Source§

fn div_assign(&mut self, rhs: u24)

Performs the /= operation. Read more
Source§

impl From<f32> for u24

Source§

fn from(v: f32) -> u24

Converts to this type from the input type.
Source§

impl From<f64> for u24

Source§

fn from(v: f64) -> u24

Converts to this type from the input type.
Source§

impl From<i128> for u24

Source§

fn from(v: i128) -> u24

Converts to this type from the input type.
Source§

impl From<i16> for u24

Source§

fn from(v: i16) -> u24

Converts to this type from the input type.
Source§

impl From<i24> for u24

Source§

fn from(v: i24) -> u24

Converts to this type from the input type.
Source§

impl From<i32> for u24

Source§

fn from(v: i32) -> u24

Converts to this type from the input type.
Source§

impl From<i64> for u24

Source§

fn from(v: i64) -> u24

Converts to this type from the input type.
Source§

impl From<i8> for u24

Source§

fn from(v: i8) -> u24

Converts to this type from the input type.
Source§

impl From<u128> for u24

Source§

fn from(v: u128) -> u24

Converts to this type from the input type.
Source§

impl From<u16> for u24

Source§

fn from(v: u16) -> u24

Converts to this type from the input type.
Source§

impl From<u24> for i24

Source§

fn from(v: u24) -> i24

Converts to this type from the input type.
Source§

impl From<u32> for u24

Source§

fn from(v: u32) -> u24

Converts to this type from the input type.
Source§

impl From<u64> for u24

Source§

fn from(v: u64) -> u24

Converts to this type from the input type.
Source§

impl From<u8> for u24

Source§

fn from(v: u8) -> u24

Converts to this type from the input type.
Source§

impl Hash for u24

Source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Into<f32> for u24

Source§

fn into(self) -> f32

Converts this type into the (usually inferred) input type.
Source§

impl Into<f64> for u24

Source§

fn into(self) -> f64

Converts this type into the (usually inferred) input type.
Source§

impl Into<i128> for u24

Source§

fn into(self) -> i128

Converts this type into the (usually inferred) input type.
Source§

impl Into<i16> for u24

Source§

fn into(self) -> i16

Converts this type into the (usually inferred) input type.
Source§

impl Into<i32> for u24

Source§

fn into(self) -> i32

Converts this type into the (usually inferred) input type.
Source§

impl Into<i64> for u24

Source§

fn into(self) -> i64

Converts this type into the (usually inferred) input type.
Source§

impl Into<i8> for u24

Source§

fn into(self) -> i8

Converts this type into the (usually inferred) input type.
Source§

impl Into<u128> for u24

Source§

fn into(self) -> u128

Converts this type into the (usually inferred) input type.
Source§

impl Into<u16> for u24

Source§

fn into(self) -> u16

Converts this type into the (usually inferred) input type.
Source§

impl Into<u32> for u24

Source§

fn into(self) -> u32

Converts this type into the (usually inferred) input type.
Source§

impl Into<u64> for u24

Source§

fn into(self) -> u64

Converts this type into the (usually inferred) input type.
Source§

impl Into<u8> for u24

Source§

fn into(self) -> u8

Converts this type into the (usually inferred) input type.
Source§

impl Mul for u24

Source§

type Output = u24

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: u24) -> <u24 as Mul>::Output

Performs the * operation. Read more
Source§

impl MulAssign for u24

Source§

fn mul_assign(&mut self, rhs: u24)

Performs the *= operation. Read more
Source§

impl Not for u24

Source§

type Output = u24

The resulting type after applying the ! operator.
Source§

fn not(self) -> <u24 as Not>::Output

Performs the unary ! operation. Read more
Source§

impl Ord for u24

Source§

fn cmp(&self, other: &u24) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for u24

Source§

fn eq(&self, other: &u24) -> 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 PartialOrd for u24

Source§

fn partial_cmp(&self, other: &u24) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Rem for u24

Source§

type Output = u24

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: u24) -> <u24 as Rem>::Output

Performs the % operation. Read more
Source§

impl RemAssign for u24

Source§

fn rem_assign(&mut self, rhs: u24)

Performs the %= operation. Read more
Source§

impl SampleFrom for u24

Source§

type ImplFor = u24

The type we are implementating for
Source§

fn to<S>(s: S) -> u24
where S: SampleType,

The to<S> method, input any type of SampleType value, then scale it to ImplFor type.
Source§

fn as_<S>(s: S) -> u24
where S: SampleType,

The as_<S> method, input any type of SampleType value, then cast it to ImplFor type.
Source§

fn sin<S>(s: S) -> u24
where S: SampleType,

Sine wave generator Read more
Source§

fn cos<S>(s: S) -> u24
where S: SampleType,

Cosine wave generator Read more
Source§

impl SampleType for u24

Source§

const MIDNUM: u24

The middle number, e.g. for u16, the middle number is 32768.
Source§

const TYPE_NAME: &'static str = "u24"

The type name, to avoid using std::any::type_name
Source§

type ImplFor = u24

The type we are implementating for
Source§

type Longer = u32

The longer type, e.g. for i8, the longer type is i16
Source§

type Shorter = u16

The shorter type, e.g. for i16, the shorter type is i8
Source§

type Signed = i24

The signed type, e.g. for u32, the signed type is i32.
Source§

type Unsigned = u24

The Unsigned type, e.g. for i32, the unsigned type is u32.
Source§

fn new() -> u24

Create a new sample, the value is the middle value of the range of the format.
Source§

fn zero() -> u24

Create a new sample, the value is zero.
Source§

fn scale_from<T>(v: T) -> u24
where T: SampleType,

Scale a sample to this specified format.
Source§

fn cast_from<T>(v: T) -> u24
where T: SampleType,

Cast a sample to this specified format.
Source§

fn average(s1: u24, s2: u24) -> u24

Get the average value of two samples.
Source§

fn average_arr(arr: &[u24]) -> u24

Get the average value from a sample array.
Source§

fn to_i8(self) -> i8

Scale to i8 range
Source§

fn to_i16(self) -> i16

Scale to i16 range
Source§

fn to_i24(self) -> i24

Scale to i24 range
Source§

fn to_i32(self) -> i32

Scale to i32 range
Source§

fn to_i64(self) -> i64

Scale to i64 range
Source§

fn to_u8(self) -> u8

Scale to u8 range
Source§

fn to_u16(self) -> u16

Scale to u16 range
Source§

fn to_u24(self) -> u24

Scale to u24 range
Source§

fn to_u32(self) -> u32

Scale to u32 range
Source§

fn to_u64(self) -> u64

Scale to u64 range
Source§

fn to_f32(self) -> f32

Scale to [-1.0, 1.0] range
Source§

fn to_f64(self) -> f64

Scale to [-1.0, 1.0] range
Source§

fn to_i128(self) -> i128

Scale to i128 range
Source§

fn to_u128(self) -> u128

Scale to u128 range
Source§

fn as_i8(self) -> i8

Cast to i8
Source§

fn as_i16(self) -> i16

Cast to i16
Source§

fn as_i24(self) -> i24

Cast to i24
Source§

fn as_i32(self) -> i32

Cast to i32
Source§

fn as_i64(self) -> i64

Cast to i64
Source§

fn as_u8(self) -> u8

Cast to u8
Source§

fn as_u16(self) -> u16

Cast to u16
Source§

fn as_u24(self) -> u24

Cast to u24
Source§

fn as_u32(self) -> u32

Cast to u32
Source§

fn as_u64(self) -> u64

Cast to u64
Source§

fn as_f32(self) -> f32

Cast to f32
Source§

fn as_f64(self) -> f64

Cast to f64
Source§

fn as_i128(self) -> i128

Cast to i128
Source§

fn as_u128(self) -> u128

Cast to u128
Source§

fn clamp_to_i8(self) -> i8

Clamp to i8
Source§

fn clamp_to_i16(self) -> i16

Clamp to i16
Source§

fn clamp_to_i24(self) -> i24

Clamp to i24
Source§

fn clamp_to_i32(self) -> i32

Clamp to i32
Source§

fn clamp_to_i64(self) -> i64

Clamp to i64
Source§

fn clamp_to_u8(self) -> u8

Clamp to u8
Source§

fn clamp_to_u16(self) -> u16

Clamp to u16
Source§

fn clamp_to_u24(self) -> u24

Clamp to u24
Source§

fn clamp_to_u32(self) -> u32

Clamp to u32
Source§

fn clamp_to_u64(self) -> u64

Clamp to u64
Source§

fn clamp_to_f32(self) -> f32

Clamp to f32
Source§

fn clamp_to_f64(self) -> f64

Clamp to f64
Source§

fn clamp_to_i128(self) -> i128

Clamp to i128
Source§

fn clamp_to_u128(self) -> u128

Clamp to u128
Source§

fn to_longer(self) -> <u24 as SampleType>::Longer

Scale to a longer type, the longest type is i128 or u128
Source§

fn to_shorter(self) -> <u24 as SampleType>::Shorter

Scale to a shorter type, the shortest type is i8 or u8
Source§

fn as_longer(self) -> <u24 as SampleType>::Longer

Cast to a longer type, the longest type is i128 or u128
Source§

fn as_shorter(self) -> <u24 as SampleType>::Shorter

Cast to a shorter type, the shortest type is i8 or u8
Source§

fn is_signed() -> bool

Is this type a signed type?
Source§

fn is_unsigned() -> bool

Is this type an unsigned type?
Source§

fn is_integer() -> bool

Is this type an integer type?
Source§

fn is_float() -> bool

Is this type an IEEE 754 floating point number type?
Source§

fn to_signed(self) -> <u24 as SampleType>::Signed

Convert to a signed number type. No effects to f32 and f64
Source§

fn to_unsigned(self) -> <u24 as SampleType>::Unsigned

Convert to an unsigned number type. No effects to f32 and f64
Source§

fn read_le<T>(r: &mut T) -> Result<u24, Error>
where T: Read + ?Sized,

Read from a reader by little-endian
Source§

fn read_be<T>(r: &mut T) -> Result<u24, Error>
where T: Read + ?Sized,

Read from a reader by big-endian
Source§

fn write_le<T>(self, w: &mut T) -> Result<(), Error>
where T: Write + ?Sized,

Write to a writer by little-endian
Source§

fn write_be<T>(self, w: &mut T) -> Result<(), Error>
where T: Write + ?Sized,

Write to a writer by big-endian
Source§

fn sin<S>(self) -> S
where S: SampleType,

Sine wave generator Read more
Source§

fn cos<S>(self) -> S
where S: SampleType,

Cosine wave generator Read more
Source§

fn interpolate(self, target: u24, s: f64) -> u24

interpolate between self to target by s
Source§

fn sizeof(self) -> usize

Get the size of the sample in bytes
Source§

impl Shl for u24

Source§

type Output = u24

The resulting type after applying the << operator.
Source§

fn shl(self, rhs: u24) -> <u24 as Shl>::Output

Performs the << operation. Read more
Source§

impl ShlAssign for u24

Source§

fn shl_assign(&mut self, rhs: u24)

Performs the <<= operation. Read more
Source§

impl Shr for u24

Source§

type Output = u24

The resulting type after applying the >> operator.
Source§

fn shr(self, rhs: u24) -> <u24 as Shr>::Output

Performs the >> operation. Read more
Source§

impl ShrAssign for u24

Source§

fn shr_assign(&mut self, rhs: u24)

Performs the >>= operation. Read more
Source§

impl Sub for u24

Source§

type Output = u24

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: u24) -> <u24 as Sub>::Output

Performs the - operation. Read more
Source§

impl SubAssign for u24

Source§

fn sub_assign(&mut self, rhs: u24)

Performs the -= operation. Read more
Source§

impl Copy for u24

Source§

impl Eq for u24

Source§

impl StructuralPartialEq for u24

Auto Trait Implementations§

§

impl Freeze for u24

§

impl RefUnwindSafe for u24

§

impl Send for u24

§

impl Sync for u24

§

impl Unpin for u24

§

impl UnwindSafe for u24

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<T> CopiableItem for T
where T: Default + Clone + Copy + Debug + PartialEq,

Source§

impl<T, Rhs> NumAssignOps<Rhs> for T
where T: AddAssign<Rhs> + SubAssign<Rhs> + MulAssign<Rhs> + DivAssign<Rhs> + RemAssign<Rhs>,

Source§

impl<T, Rhs, Output> NumOps<Rhs, Output> for T
where T: Sub<Rhs, Output = Output> + Mul<Rhs, Output = Output> + Div<Rhs, Output = Output> + Add<Rhs, Output = Output> + Rem<Rhs, Output = Output>,

Source§

impl<T> Numeric for T
where T: Add<Output = T> + Mul<Output = T> + Div<Output = T> + Sub<Output = T> + AddAssign + SubAssign + MulAssign + DivAssign + Debug + Display + Clone + Copy + 'static,

Source§

impl<T> SampleTypeInteger for T
where T: BitAnd<Output = T> + Shl<Output = T> + Shr<Output = T> + BitOr<Output = T> + BitAndAssign + BitOrAssign + BitXorAssign + ShlAssign + ShrAssign + Rem<Output = T> + SampleType + RemAssign + Not<Output = T> + BitXor<Output = T>,