Struct ActionBinding
pub struct ActionBinding<I> { /* private fields */ }Expand description
Type-safe adapter from a control’s input value to an exported action.
Construction requires the real Resource and ActionSpec, rather
than parallel string constants. Emission pre-validates arguments against a
clone of that spec; the host nevertheless re-resolves and validates again
at dispatch time because this object is convenience, not authority.
Implementations§
§impl<I> ActionBinding<I>
impl<I> ActionBinding<I>
pub fn new(
resource: &Resource,
spec: &ActionSpec,
arguments: impl Fn(I) -> Map<String, Value> + Send + Sync + 'static,
) -> Result<ActionBinding<I>, ActionBindingError>
pub fn new( resource: &Resource, spec: &ActionSpec, arguments: impl Fn(I) -> Map<String, Value> + Send + Sync + 'static, ) -> Result<ActionBinding<I>, ActionBindingError>
Bind a typed control value to arguments for an action actually exported
by resource.
§Errors
Returns ActionBindingError::ActionNotExported if spec is absent
from resource.
pub fn fallible(
resource: &Resource,
spec: &ActionSpec,
arguments: impl Fn(I) -> Result<Map<String, Value>, String> + Send + Sync + 'static,
) -> Result<ActionBinding<I>, ActionBindingError>
pub fn fallible( resource: &Resource, spec: &ActionSpec, arguments: impl Fn(I) -> Result<Map<String, Value>, String> + Send + Sync + 'static, ) -> Result<ActionBinding<I>, ActionBindingError>
Self::new for an input that may not make arguments: a value that
does not serialize, a form that does not fit the parameters. Such an
input is refused when the control emits it, never sent empty.
§Errors
Returns ActionBindingError::ActionNotExported if spec is absent
from resource.
pub fn invoke(&self, input: I) -> Result<ControlInvocation, ActionBindingError>
pub fn invoke(&self, input: I) -> Result<ControlInvocation, ActionBindingError>
Produce a host-routable intent after strict parameter validation.
§Errors
Returns ActionBindingError::InvalidArguments if the mapped input
violates the exported action’s parameter contract.
pub fn address(&self) -> &ActionAddress
§impl ActionBinding<()>
impl ActionBinding<()>
pub fn unit(
resource: &Resource,
spec: &ActionSpec,
) -> Result<ActionBinding<()>, ActionBindingError>
pub fn unit( resource: &Resource, spec: &ActionSpec, ) -> Result<ActionBinding<()>, ActionBindingError>
Bind a nullary control to a nullary exported action.
§Errors
Returns an error if the action is not exported or requires arguments.
pub fn unit_for(
resource: &Resource,
action_id: &str,
) -> Result<ActionBinding<()>, ActionBindingError>
pub fn unit_for( resource: &Resource, action_id: &str, ) -> Result<ActionBinding<()>, ActionBindingError>
Look up the real exported spec by stable id, then create a nullary binding. Useful when the resource is assembled inline or generated.
§Errors
Returns an error if action_id is not exported or requires arguments.
pub fn static_json(
resource: &Resource,
spec: &ActionSpec,
arguments: Map<String, Value>,
) -> Result<ActionBinding<()>, ActionBindingError>
pub fn static_json( resource: &Resource, spec: &ActionSpec, arguments: Map<String, Value>, ) -> Result<ActionBinding<()>, ActionBindingError>
Bind a control to a fixed, strictly validated JSON argument object.
§Errors
Returns an error if the action is not exported or arguments violate
its parameter contract.
pub fn static_json_for(
resource: &Resource,
action_id: &str,
arguments: Map<String, Value>,
) -> Result<ActionBinding<()>, ActionBindingError>
pub fn static_json_for( resource: &Resource, action_id: &str, arguments: Map<String, Value>, ) -> Result<ActionBinding<()>, ActionBindingError>
Look up the real exported spec by id, then bind fixed JSON arguments.
§Errors
Returns an error if action_id is not exported or arguments violate
its parameter contract.
Trait Implementations§
§impl<I> Clone for ActionBinding<I>where
I: Clone,
impl<I> Clone for ActionBinding<I>where
I: Clone,
§fn clone(&self) -> ActionBinding<I>
fn clone(&self) -> ActionBinding<I>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl<I> Freeze for ActionBinding<I>
impl<I> !RefUnwindSafe for ActionBinding<I>
impl<I> Send for ActionBinding<I>
impl<I> Sync for ActionBinding<I>
impl<I> Unpin for ActionBinding<I>
impl<I> UnsafeUnpin for ActionBinding<I>
impl<I> !UnwindSafe for ActionBinding<I>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
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>
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