Skip to main content

AddonParam

Struct AddonParam 

Source
pub struct AddonParam {
    pub id: &'static str,
    pub name: &'static str,
    pub description: &'static str,
    pub kind: ParamKind,
    pub required: bool,
    pub multiple: bool,
    pub choices: Option<&'static str>,
}
Expand description

One thing an action needs to know, declared so an interface can ask for it.

The point of declaring rather than parsing a free-text argument: FR-048 wants addon configuration built from the shared component library, and there has to be something to build it from. A third-party addon gets the same editor as a first-party one with no code in the interface.

Fields§

§id: &'static str

Stable identifier, and the key a binding stores it under. Renaming one silently drops whatever the user had chosen.

§name: &'static str

What to call it.

§description: &'static str

What it is for, in a sentence.

§kind: ParamKind

What it holds.

§required: bool

Whether the action can run without it.

An optional parameter is a real thing rather than an oversight: the media addon’s target application is absent for “whatever is playing”, which is the behaviour most people want most of the time.

§multiple: bool

Whether it holds several values rather than one (006-FR-024a-i).

Orthogonal to Self::kind on purpose. What a value means and how many of them there are are different questions, and folding one into the other is what produces AppList, ParticipantList, PlaylistList — one new kind every time somebody wants a list of something.

§choices: Option<&'static str>

The id of an AddonChoices this draws its options from, if any.

None is free text, which is what every parameter was before ADR-0022 and what a choice-backed one degrades to when its list is unavailable.

Implementations§

Source§

impl AddonParam

Source

pub const BASE: Self

A parameter with nothing set, to build from.

Exists so the next field added here does not break every const array an addon writes: AddonParam { id: "app", ..AddonParam::BASE } compiles in a const, and adding a field to BASE costs its authors nothing. It does not save the arrays that already name every field, which is why the ones in this repository were converted when this was added.

Trait Implementations§

Source§

impl Clone for AddonParam

Source§

fn clone(&self) -> AddonParam

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 Debug for AddonParam

Source§

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

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

impl PartialEq for AddonParam

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for AddonParam

Source§

impl Eq for AddonParam

Source§

impl StructuralPartialEq for AddonParam

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.