Skip to main content

ActionArgs

Struct ActionArgs 

Source
pub struct ActionArgs { /* private fields */ }
Expand description

Arguments for one invocation, already checked against the action’s declared parameters.

There is no way to build one except through bind or none, so an action’s builder never has to re-validate: if it holds an ActionArgs, every required parameter is present and every value has the declared type. That is what keeps a bad call from becoming a half-applied edit.

Implementations§

Source§

impl ActionArgs

Source

pub fn none() -> Self

The empty argument set — what a nullary action is invoked with.

Source

pub fn from(&self) -> Option<&MadeFrom>

The resource this invocation is made from, when it is made from one.

Source

pub fn with_from(self, from: Option<MadeFrom>) -> Self

This invocation as one made from from.

Source

pub fn bind( params: &[ActionParam], supplied: impl IntoIterator<Item = (String, ArgValue)>, ) -> Result<Self, ArgError>

Check supplied against params and bind it.

Fails on the first problem rather than accumulating: the caller has to fix them one at a time anyway, and a partial bind must never reach an action.

Source

pub fn bind_json( params: &[ActionParam], supplied: &Map<String, Value>, ) -> Result<Self, ArgError>

Bind arguments that arrived as a JSON object — the shape a control socket delivers.

Source

pub fn text(&self, name: &str) -> Option<&str>

Source

pub fn integer(&self, name: &str) -> Option<i64>

The integer bound to name, where it fits one a caller works in.

Source

pub fn whole(&self, name: &str) -> Option<u64>

The whole number bound to name, as wide as the id it names.

Source

pub fn array(&self, name: &str) -> Option<&[Value]>

Source

pub fn number(&self, name: &str) -> Option<f64>

The number bound to name, if any. An integer argument widens, matching ArgValue::satisfies.

Source

pub fn boolean(&self, name: &str) -> Option<bool>

Source

pub fn get(&self, name: &str) -> Option<&ArgValue>

The raw bound value, for a caller that wants to switch on the type.

Source

pub fn is_empty(&self) -> bool

Whether anything is bound.

Source

pub fn to_json(&self) -> Map<String, Value>

Every bound argument as JSON — the inverse of bind_json, so a caller can echo back exactly what it sent.

Trait Implementations§

Source§

impl Clone for ActionArgs

Source§

fn clone(&self) -> Self

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 ActionArgs

Source§

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

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

impl Default for ActionArgs

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl PartialEq for ActionArgs

Source§

fn eq(&self, other: &Self) -> 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 ActionArgs

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more