Skip to main content

ConstantMask

Struct ConstantMask 

Source
pub struct ConstantMask(/* private fields */);
Expand description

A hint that indicates which channels of an audio port are constant.

Channels are defined as constant when all of their samples have the exact same value. This however doesn’t mean they are silent: the value could be different from 0.

This type is internally by a 64-bit bitmask, as per the CLAP specification, hence its name. This also means a constant mask can only hold constant hints for up to 64 channels: information about any extra channels is lost, and this implementation considers those channels to never be constant.

§Example

use clack_common::process::ConstantMask;

let mut constant_mask = ConstantMask::from_bits(0b101);

assert!(constant_mask.is_channel_constant(0));
assert!(!constant_mask.is_channel_constant(1));
assert!(constant_mask.is_channel_constant(2));

constant_mask.set_channel_constant(1, true);
assert!(constant_mask.is_channel_constant(1));
assert_eq!(0b111, constant_mask.to_bits());

Implementations§

Source§

impl ConstantMask

Source

pub const CAPACITY: u8 = 64

The capacity, in bits, of a ConstantMask.

This is how many channels can be represented in a ConstantMask.

Source

pub const FULLY_CONSTANT: ConstantMask

A ConstantMask that represents all 64 possible channels as being fully constant. This constant mask has all its bits set to 1.

Source

pub const FULLY_DYNAMIC: ConstantMask

A ConstantMask that represents all 64 possible channels as being fully dynamic. This constant mask has all its bits set to 0.

Source

pub const fn from_bits(bits: u64) -> ConstantMask

Creates a new constant mask from its inner bitmask representation.

Source

pub const fn to_bits(&self) -> u64

Gets the constant mask’s inner bitmask representation.

Source

pub const fn iter(&self) -> ConstantMaskIter ⓘ

Returns an iterator over the constant status of each channel in this constant mask.

§Example
use clack_common::process::ConstantMask;

let mut iter = ConstantMask::from_bits(0b101).iter();

assert_eq!(Some(true), iter.next());
assert_eq!(Some(false), iter.next());
assert_eq!(Some(true), iter.next());
assert_eq!(Some(false), iter.next());
assert_eq!(Some(false), iter.next());
Source

pub const fn is_channel_constant(&self, channel_index: u64) -> bool

Returns true if the channel at the given index is constant, false otherwise.

This function will always return false when given any index over 63.

Source

pub const fn set_channel_constant(&mut self, channel_index: u64, value: bool)

Sets whether the channel at the given index is constant.

This function does nothing when given any index over 63.

Trait Implementations§

Source§

impl BitAnd for ConstantMask

Source§

type Output = ConstantMask

The resulting type after applying the & operator.
Source§

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

Performs the & operation. Read more
Source§

impl BitAndAssign for ConstantMask

Source§

fn bitand_assign(&mut self, rhs: ConstantMask)

Performs the &= operation. Read more
Source§

impl BitOr for ConstantMask

Source§

type Output = ConstantMask

The resulting type after applying the | operator.
Source§

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

Performs the | operation. Read more
Source§

impl BitOrAssign for ConstantMask

Source§

fn bitor_assign(&mut self, rhs: ConstantMask)

Performs the |= operation. Read more
Source§

impl BitXor for ConstantMask

Source§

type Output = ConstantMask

The resulting type after applying the ^ operator.
Source§

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

Performs the ^ operation. Read more
Source§

impl BitXorAssign for ConstantMask

Source§

fn bitxor_assign(&mut self, rhs: ConstantMask)

Performs the ^= operation. Read more
Source§

impl Clone for ConstantMask

Source§

fn clone(&self) -> ConstantMask

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for ConstantMask

Source§

impl Debug for ConstantMask

Source§

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

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

impl Default for ConstantMask

Source§

fn default() -> ConstantMask

Returns an empty constant mask, i.e. one where every channel is considered dynamic.

Source§

impl Eq for ConstantMask

Source§

impl IntoIterator for ConstantMask

Source§

type Item = bool

The type of the elements being iterated over.
Source§

type IntoIter = ConstantMaskIter

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> <ConstantMask as IntoIterator>::IntoIter

Creates an iterator from a value. Read more
Source§

impl IntoIterator for &ConstantMask

Source§

type Item = bool

The type of the elements being iterated over.
Source§

type IntoIter = ConstantMaskIter

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> <&ConstantMask as IntoIterator>::IntoIter

Creates an iterator from a value. Read more
Source§

impl IntoIterator for &mut ConstantMask

Source§

type Item = bool

The type of the elements being iterated over.
Source§

type IntoIter = ConstantMaskIter

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> <&mut ConstantMask as IntoIterator>::IntoIter

Creates an iterator from a value. Read more
Source§

impl PartialEq for ConstantMask

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ConstantMask

Auto Trait Implementations§

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.