pub struct EnumParam<E: ParamEnum> {
pub info: ParamInfo,
/* private fields */
}Expand description
An enum parameter.
Fields§
§info: ParamInfoImplementations§
Source§impl<E: ParamEnum> EnumParam<E>
impl<E: ParamEnum> EnumParam<E>
Sourcepub fn new(info: ParamInfo) -> Self
pub fn new(info: ParamInfo) -> Self
§Panics
Panics if info.default_plain is non-finite, negative, or
>= E::variant_count(). The cast f64 as u32 saturates
silently - a user-supplied #[param(default = -1)] would
land on variant 0 without any signal that the default was
invalid. Validate up front so the bug surfaces at plugin
construction time.
pub fn value(&self) -> E
pub fn set_value(&self, v: E)
pub fn set_index(&self, idx: u32)
pub fn index(&self) -> u32
pub fn id(&self) -> u32
Sourcepub fn format_by_index(value: f64) -> String
pub fn format_by_index(value: f64) -> String
Format a plain value (index as f64) to the variant name string.
Associated function - the dispatch is purely on E, no instance
state is read. The #[derive(Params)] macro calls it as
<EnumParam<E>>::format_by_index(value) so the field type
supplies E.
Auto Trait Implementations§
impl<E> !Freeze for EnumParam<E>
impl<E> RefUnwindSafe for EnumParam<E>where
E: RefUnwindSafe,
impl<E> Send for EnumParam<E>
impl<E> Sync for EnumParam<E>
impl<E> Unpin for EnumParam<E>where
E: Unpin,
impl<E> UnsafeUnpin for EnumParam<E>
impl<E> UnwindSafe for EnumParam<E>where
E: UnwindSafe,
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