pub struct StatesMap { /* private fields */ }Expand description
Implementations§
Source§impl StatesMap
impl StatesMap
Sourcepub fn new_override_defaults<'a, S: AsRef<str> + 'a>(
infos: impl IntoIterator<Item = InfoRef<'a, S>> + 'a,
overrides: &HashMap<&str, InternalValue>,
) -> Self
pub fn new_override_defaults<'a, S: AsRef<str> + 'a>( infos: impl IntoIterator<Item = InfoRef<'a, S>> + 'a, overrides: &HashMap<&str, InternalValue>, ) -> Self
Create a new StatesMap from a list of Infos and overrides.
This creates a StatesMap with all parameters set to default values,
except for the ones that are overridden by the overrides.
Note that if you want to pass this into a synth, you should use
SynthStatesMap::new_override_defaults instead.
overrides work exactly as in override_defaults.
§Examples
let infos = vec![
StaticInfoRef {
title: "Numeric",
short_title: "Numeric",
unique_id: "numeric",
flags: Default::default(),
type_specific: TypeSpecificInfoRef::Numeric {
default: 0.0,
valid_range: 0.0..=1.0,
units: None,
},
},
];
let overrides = vec![("numeric", InternalValue::Numeric(0.5))].into_iter().collect();
let states = StatesMap::new_override_defaults(infos.iter().cloned(), &overrides);
assert_eq!(states.get_numeric("numeric"), Some(0.5));Sourcepub fn new_defaults<'a, S: AsRef<str> + 'a>(
infos: impl IntoIterator<Item = InfoRef<'a, S>> + 'a,
) -> Self
pub fn new_defaults<'a, S: AsRef<str> + 'a>( infos: impl IntoIterator<Item = InfoRef<'a, S>> + 'a, ) -> Self
Create a new StatesMap from a list of Infos.
Each parameter in Infos will be set to its default value.
Note that if you want to pass this into a synth, you should use
[Self::new_synth_defaults] instead.
§Examples
let infos = vec![
StaticInfoRef {
title: "Numeric",
short_title: "Numeric",
unique_id: "numeric",
flags: Default::default(),
type_specific: TypeSpecificInfoRef::Numeric {
default: 0.0,
valid_range: 0.0..=1.0,
units: None,
},
},
];
let states = StatesMap::new_defaults(infos.iter().cloned());
assert_eq!(states.get_numeric("numeric"), Some(0.0));Trait Implementations§
Source§impl<S: AsRef<str>> From<HashMap<S, InternalValue>> for StatesMap
impl<S: AsRef<str>> From<HashMap<S, InternalValue>> for StatesMap
Source§fn from(map: HashMap<S, InternalValue>) -> Self
fn from(map: HashMap<S, InternalValue>) -> Self
Converts to this type from the input type.
Source§impl States for StatesMap
impl States for StatesMap
Source§fn get_by_hash(&self, id_hash: IdHash) -> Option<InternalValue>
fn get_by_hash(&self, id_hash: IdHash) -> Option<InternalValue>
Get the current value of a parameter by it’s hashed unique ID. Read more
Source§fn get(&self, unique_id: &str) -> Option<InternalValue>
fn get(&self, unique_id: &str) -> Option<InternalValue>
Get the current value of a parameter by it’s unique ID. Read more
Source§fn numeric_by_hash(&self, id_hash: IdHash) -> Option<f32>
fn numeric_by_hash(&self, id_hash: IdHash) -> Option<f32>
Get the current numeric value of a parameter by it’s hashed unique ID. Read more
Source§fn get_numeric(&self, unique_id: &str) -> Option<f32>
fn get_numeric(&self, unique_id: &str) -> Option<f32>
Get the current numeric value of a parameter by it’s unique ID. Read more
Source§fn enum_by_hash(&self, id_hash: IdHash) -> Option<u32>
fn enum_by_hash(&self, id_hash: IdHash) -> Option<u32>
Get the current enum value of a parameter by it’s hashed unique ID. Read more
Source§fn get_enum(&self, unique_id: &str) -> Option<u32>
fn get_enum(&self, unique_id: &str) -> Option<u32>
Get the current enum value of a parameter by it’s unique ID. Read more
Auto Trait Implementations§
impl Freeze for StatesMap
impl RefUnwindSafe for StatesMap
impl Send for StatesMap
impl Sync for StatesMap
impl Unpin for StatesMap
impl UnwindSafe for StatesMap
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more