Skip to main content

Effect

Trait Effect 

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

Source

const OPERATION: &'static str

The operation type every effect of the vocabulary travels under: unique per vocabulary, like a resource’s kind.

Provided Associated Constants§

Source

const APP_ID: &'static str = crate::kind::DEFAULT_APP

The app whose resource offers the vocabulary’s effects, which an effect’s typed reference names its action by: defaults to none of its own, for a vocabulary that is not an app’s (a test’s, a host’s).

Source

const LABEL: &'static str = Self::OPERATION

The vocabulary’s name, as its effects are labelled when they are offered on their own.

Required Methods§

Source

fn declarations() -> Vec<EffectDecl>

One declaration per effect, in order.

Source

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.

Source

fn id(&self) -> &'static str

This effect’s id among the declarations.

Source

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

This effect’s arguments, named as its declaration’s parameters.

Source

fn decode( id: &str, arguments: &Map<String, Value>, ) -> Result<Self, EffectDecodeError>

The effect id with arguments, as a caller invoked it.

Provided Methods§

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

fn specs() -> Vec<ActionSpec>

The published action of every effect offered on the resource: all but the row ones, which are offered only bound.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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".

Implementors§

Source§

impl Effect for NoEffect

Source§

const OPERATION: &'static str = "tilo.no-effect"