pub trait Effect: Sized + 'static {
const OPERATION: &'static str;
const APP_ID: &'static str = crate::kind::DEFAULT_APP;
const LABEL: &'static str = Self::OPERATION;
Show 19 methods
// Required methods
fn declarations() -> Vec<EffectDecl>;
fn rows() -> Vec<EffectRow>;
fn id(&self) -> &'static str;
fn arguments(&self) -> Map<String, Value>;
fn decode(
id: &str,
arguments: &Map<String, Value>,
) -> Result<Self, EffectDecodeError>;
// Provided methods
fn declaration(id: &str) -> Option<EffectDecl> { ... }
fn confirmation_phrase(&self) -> Option<String> { ... }
fn kind() -> ResourceKind { ... }
fn key(&self) -> ActionKey { ... }
fn spec(id: &str) -> Option<ActionSpec> { ... }
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 row_specs(kind: &'static str, row: &Id) -> Vec<ActionSpec> { ... }
fn row_specs_with(
kind: &'static str,
_row: &Id,
bindings: &RowBindings,
) -> Vec<ActionSpec> { ... }
fn address_on(&self, resource: impl Into<String>) -> ActionAddress { ... }
fn from_payload(payload: &[u8]) -> Result<Self, EffectDecodeError> { ... }
}Expand description
A typed vocabulary of effects. Derive it (#[derive(Effect)]); see the
module docs.
Required Associated Constants§
Provided Associated Constants§
Required Methods§
Sourcefn declarations() -> Vec<EffectDecl>
fn declarations() -> Vec<EffectDecl>
One declaration per effect, in order.
Sourcefn rows() -> Vec<EffectRow>
fn rows() -> Vec<EffectRow>
The vocabulary’s declarations where they are kept, for a surface that publishes an app without running it: every area’s, for a vocabulary that gathers several.
Provided Methods§
Sourcefn 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.
Sourcefn confirmation_phrase(&self) -> Option<String>
fn confirmation_phrase(&self) -> Option<String>
What its caller types to confirm this invocation, when its effect
declares phrase: the name of what it erases.
Sourcefn kind() -> ResourceKind
fn kind() -> ResourceKind
The kind the vocabulary’s effects are published under, which a typed reference to one names: the operation they travel as, the vocabulary’s name, and the app that offers it.
Sourcefn key(&self) -> ActionKey
fn key(&self) -> ActionKey
The key this effect is offered under: the app that offers the vocabulary, the operation its effects travel as, and this effect’s id.
Sourcefn spec(id: &str) -> Option<ActionSpec>
fn spec(id: &str) -> Option<ActionSpec>
The spec id declares: what a control binding it reads, so binding one
effect costs one declaration rather than the vocabulary’s.
Sourcefn 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.
Sourcefn 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.
Sourcefn 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.
Sourcefn 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.
Sourcefn 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.
Sourcefn row_specs(kind: &'static str, row: &Id) -> Vec<ActionSpec>
fn row_specs(kind: &'static str, row: &Id) -> Vec<ActionSpec>
The effects offered on the row row of the
RowType kind (#[effect(on = Row)]),
each with its first parameter bound to the row and the rest still
asked. RowType::effects calls it.
Sourcefn row_specs_with(
kind: &'static str,
_row: &Id,
bindings: &RowBindings,
) -> Vec<ActionSpec>
fn row_specs_with( kind: &'static str, _row: &Id, bindings: &RowBindings, ) -> Vec<ActionSpec>
The effects offered on the row row of the
RowType kind, those bindings names
among them, each with exactly the arguments they give bound and the
rest still asked. RowType::effects_with
calls it.
Sourcefn address_on(&self, resource: impl Into<String>) -> ActionAddress
fn address_on(&self, resource: impl Into<String>) -> ActionAddress
This effect as the published resource resource offers it (the
record, or a child or live row it is bound on, by its published id):
what a search hit invokes or a caller addresses through the host’s
API. Its id comes from the effect itself.
Sourcefn from_payload(payload: &[u8]) -> Result<Self, EffectDecodeError>
fn from_payload(payload: &[u8]) -> Result<Self, EffectDecodeError>
Decode one invocation’s payload, as the operation’s specs encode it.
Read where the effect runs, as an action’s arguments are read where
it is invoked: an effect is never replayed, so content its arguments
name — a reference, or the data inline — is read from this window’s
store and kept, sealed, in it ([crate::content::invoking]).
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".