pub struct ControlMeta {
pub id: ControlId,
pub name: String,
pub kind: ControlKind,
pub access: Access,
pub min: ControlValue,
pub max: ControlValue,
pub default: ControlValue,
pub step: Option<ControlValue>,
pub menu: Option<Vec<String>>,
}Expand description
Simplified control metadata.
§Example
use styx_core::prelude::{Access, ControlId, ControlKind, ControlMeta, ControlValue};
let meta = ControlMeta {
id: ControlId(1),
name: "gain".into(),
kind: ControlKind::Uint,
access: Access::ReadWrite,
min: ControlValue::Uint(0),
max: ControlValue::Uint(255),
default: ControlValue::Uint(16),
step: Some(ControlValue::Uint(1)),
menu: None,
};
assert!(meta.validate(&ControlValue::Uint(32)));Fields§
§id: ControlIdStable identifier.
name: StringHuman-readable name.
kind: ControlKindKind of control/value type.
access: AccessAccess permissions.
min: ControlValueMinimum accepted value.
max: ControlValueMaximum accepted value.
default: ControlValueDefault value.
step: Option<ControlValue>Optional step size for ranged controls.
Optional enumerated menu entries (for menu controls).
Implementations§
Source§impl ControlMeta
impl ControlMeta
Sourcepub fn validate(&self, candidate: &ControlValue) -> bool
pub fn validate(&self, candidate: &ControlValue) -> bool
Basic range validation respecting the variant.
§Example
use styx_core::prelude::{Access, ControlId, ControlKind, ControlMeta, ControlValue};
let meta = ControlMeta {
id: ControlId(1),
name: "brightness".into(),
kind: ControlKind::Int,
access: Access::ReadWrite,
min: ControlValue::Int(-10),
max: ControlValue::Int(10),
default: ControlValue::Int(0),
step: Some(ControlValue::Int(1)),
menu: None,
};
assert!(meta.validate(&ControlValue::Int(5)));Trait Implementations§
Source§impl Clone for ControlMeta
impl Clone for ControlMeta
Source§fn clone(&self) -> ControlMeta
fn clone(&self) -> ControlMeta
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for ControlMeta
impl RefUnwindSafe for ControlMeta
impl Send for ControlMeta
impl Sync for ControlMeta
impl Unpin for ControlMeta
impl UnwindSafe for ControlMeta
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