Enum Sample

pub enum Sample

A single red, green, blue, or alpha value.

Variants

F16(f16)

A 16-bit float sample.

F32(f32)

A 32-bit float sample.

U32(u32)

An unsigned integer sample.

Implementations

impl Sample

fn f32(f32: f32) -> Self

Create a sample containing a 32-bit float.

fn f16(f16: f16) -> Self

Create a sample containing a 16-bit float.

fn u32(u32: u32) -> Self

Create a sample containing a 32-bit integer.

fn to_f16(self) -> f16

Convert the sample to an f16 value. This has lower precision than f32. Note: An f32 can only represent integers up to 1024 as precise as a u32 could.

fn to_f32(self) -> f32

Convert the sample to an f32 value. Note: An f32 can only represent integers up to 8388608 as precise as a u32 could.

fn to_u32(self) -> u32

Convert the sample to a u32. Rounds floats to integers the same way that 3.1 as u32 does.

fn is_nan(self) -> bool

Is this value not a number?

fn is_zero(&self) -> bool

Is this value zero or negative zero?

Trait Implementations

impl Clone for Sample

fn clone(&self) -> Self

impl Copy for Sample

impl Debug for Sample

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

impl Default for Sample

fn default() -> Self

impl From<f16> for Sample

fn from(f: f16) -> Self

impl From<f32> for Sample

fn from(f: f32) -> Self

impl From<u32> for Sample

fn from(f: u32) -> Self

impl FromNativeSample for Sample

fn from_f16(value: f16) -> Self
fn from_f32(value: f32) -> Self
fn from_u32(value: u32) -> Self

impl IntoNativeSample for Sample

fn to_f16(&self) -> f16
fn to_f32(&self) -> f32
fn to_u32(&self) -> u32

impl PartialEq for Sample

fn eq(&self, other: &Self) -> bool

impl ValidateResult for Sample

fn validate_result(&self, other: &Self, options: ValidationOptions, location: impl Fn() -> String) -> ValidationResult

impl<T> From<Option<T>> for Sample where T: Into<Self> + Default,

fn from(num: Option<T>) -> Self

Auto Trait Implementations

impl Freeze for Sample

impl RefUnwindSafe for Sample

impl Send for Sample

impl Sync for Sample

impl Unpin for Sample

impl UnsafeUnpin for Sample

impl UnwindSafe for Sample

Blanket Implementations

impl<R, P> ReadPrimitive<R> for Sample where R: Read + ReadEndian<P>, P: Default,

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for Sample where ST: ?Sized, DT: ?Sized,

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for Sample where ST: ?Sized, DT: ?Sized,

impl<T> Any for Sample where T: 'static + ?Sized,

fn type_id(&self) -> TypeId

impl<T> Borrow<T> for Sample where T: ?Sized,

fn borrow(&self) -> &T

impl<T> BorrowMut<T> for Sample where T: ?Sized,

fn borrow_mut(&mut self) -> &mut T

impl<T> CloneToUninit for Sample where T: Clone,

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

impl<T> From<T> for Sample

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> Pointable for Sample

const ALIGN: usize = _;
type Init = T;
unsafe fn init(init: <T as Pointable>::Init) -> usize
unsafe fn deref<'a>(ptr: usize) -> &'a T
unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T
unsafe fn drop(ptr: usize)

impl<T> Read<Exclusive, BecauseExclusive> for Sample where T: ?Sized,

impl<T> ToOwned for Sample where T: Clone,

type Owned = T;
fn to_owned(&self) -> T
fn clone_into(&self, target: &mut T)

impl<T, U> Into<U> for Sample where U: From<T>,

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom<U> for Sample where U: Into<T>,

type Error = never;
fn try_from(value: U) -> Result<T, never>

impl<T, U> TryInto<U> for Sample where U: TryFrom<T>,

type Error = <U as TryFrom<T>>::Error;
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>