Trait SampleFrom

Source
pub trait SampleFrom: Numeric {
    type ImplFor;

    // Required methods
    fn to<S>(s: S) -> Self
       where S: SampleType;
    fn as_<S>(s: S) -> Self
       where S: SampleType;
    fn sin<S>(s: S) -> Self
       where S: SampleType;
    fn cos<S>(s: S) -> Self
       where S: SampleType;
}
Expand description
  • The SampleFrom as a utility for SampleType to handle function overloading

Required Associated Types§

Source

type ImplFor

The type we are implementating for

Required Methods§

Source

fn to<S>(s: S) -> Self
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) -> Self
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) -> Self
where S: SampleType,

Sine wave generator

  • The input x doesn’t need to be related to PI.
  • e.g. The type is i8, the value is -128, then you will get sin(-PI).
  • e.g. The type is u8, the value is 0, then you will get sin(-PI) too.
Source

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

Cosine wave generator

  • The input x doesn’t need to be related to PI.
  • e.g. The type is i8, the value is -128, then you will get cos(-PI).
  • e.g. The type is u8, the value is 0, then you will get cos(-PI) too.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl SampleFrom for f32

Source§

type ImplFor = f32

Source§

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

Source§

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

Source§

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

Source§

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

Source§

impl SampleFrom for f64

Source§

type ImplFor = f64

Source§

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

Source§

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

Source§

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

Source§

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

Source§

impl SampleFrom for i8

Source§

type ImplFor = i8

Source§

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

Source§

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

Source§

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

Source§

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

Source§

impl SampleFrom for i16

Source§

type ImplFor = i16

Source§

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

Source§

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

Source§

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

Source§

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

Source§

impl SampleFrom for i32

Source§

type ImplFor = i32

Source§

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

Source§

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

Source§

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

Source§

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

Source§

impl SampleFrom for i64

Source§

type ImplFor = i64

Source§

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

Source§

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

Source§

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

Source§

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

Source§

impl SampleFrom for i128

Source§

type ImplFor = i128

Source§

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

Source§

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

Source§

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

Source§

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

Source§

impl SampleFrom for u8

Source§

type ImplFor = u8

Source§

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

Source§

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

Source§

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

Source§

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

Source§

impl SampleFrom for u16

Source§

type ImplFor = u16

Source§

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

Source§

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

Source§

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

Source§

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

Source§

impl SampleFrom for u32

Source§

type ImplFor = u32

Source§

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

Source§

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

Source§

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

Source§

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

Source§

impl SampleFrom for u64

Source§

type ImplFor = u64

Source§

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

Source§

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

Source§

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

Source§

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

Source§

impl SampleFrom for u128

Source§

type ImplFor = u128

Source§

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

Source§

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

Source§

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

Source§

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

Implementors§