Trait Effect
pub trait Effect: Sized + 'static {
const OPERATION: &'static str;
// Required methods
fn declarations() -> Vec<EffectDecl>;
fn id(&self) -> &'static str;
fn arguments(&self) -> Map<String, Value>;
fn decode(id: &str, arguments: &Map<String, Value>) -> Result<Self, String>;
// Provided methods
fn declaration(id: &str) -> Option<EffectDecl> { ... }
fn specs() -> Vec<ActionSpec> { ... }
fn bound(&self) -> ActionSpec { ... }
fn bound_asking(&self, asking: &[&str]) -> ActionSpec { ... }
fn bound_asking_params(&self, params: Vec<ActionParam>) -> ActionSpec { ... }
fn item_specs(field: &str, item: &Id) -> Vec<ActionSpec> { ... }
fn from_payload(payload: &[u8]) -> Result<Self, String> { ... }
}Expand description
A typed vocabulary of effects. Derive it (#[derive(Effect)]); see the
module docs.
Required Associated Constants§
Required Methods§
fn declarations() -> Vec<EffectDecl>
fn declarations() -> Vec<EffectDecl>
One declaration per effect, in order.
Provided Methods§
fn declaration(id: &str) -> Option<EffectDecl>
fn declaration(id: &str) -> Option<EffectDecl>
The declaration of the effect id, built alone: what binding one
effect to an item reads, so offering it on many items costs one
declaration each, not the whole vocabulary.
fn specs() -> Vec<ActionSpec>
fn specs() -> Vec<ActionSpec>
The published action of every effect offered on the resource: all
but the row ones, which are offered only bound.
fn bound(&self) -> ActionSpec
fn bound(&self) -> ActionSpec
This effect with its arguments as one action that takes none: what a published child or a live row offers (open this snippet, stop this process), answered by the vocabulary’s handler like any other invocation of the effect, under the same contract as its declaration.
fn bound_asking(&self, asking: &[&str]) -> ActionSpec
fn bound_asking(&self, asking: &[&str]) -> ActionSpec
This effect bound to the item it acts on, as bound,
still asking its caller for the arguments named in asking: rename
this file, to a name the caller gives. The bound arguments are this
effect’s own; an asked one the caller supplies replaces it.
fn bound_asking_params(&self, params: Vec<ActionParam>) -> ActionSpec
fn bound_asking_params(&self, params: Vec<ActionParam>) -> ActionSpec
bound_asking with the asked parameters given
whole, narrowed for this item: the applications that can open this
file as the choices of app.
fn item_specs(field: &str, item: &Id) -> Vec<ActionSpec>
fn item_specs(field: &str, item: &Id) -> Vec<ActionSpec>
The effects offered on the item item of the collection field
(#[effect(item = field)]), each with its first parameter bound to
the item and the rest still asked.
fn from_payload(payload: &[u8]) -> Result<Self, String>
fn from_payload(payload: &[u8]) -> Result<Self, String>
Decode one invocation’s payload, as the operation’s specs encode it.
§Errors
Returns why the payload is not an effect of this vocabulary.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.