Skip to main content

Effect

Trait Effect 

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 16 methods // 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, 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 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§

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§

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

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

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

Required Methods§

fn declarations() -> Vec<EffectDecl>

One declaration per effect, in order.

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

This effect’s id among the declarations.

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

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

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

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

Provided Methods§

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 confirmation_phrase(&self) -> Option<String>

What its caller types to confirm this invocation, when its effect declares phrase: the name of what it erases.

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.

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.

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.

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

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

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

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>

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 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 door. Its id comes from the effect itself.

fn from_payload(payload: &[u8]) -> Result<Self, EffectDecodeError>

Decode one invocation’s payload, as the operation’s specs encode it.

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.

Implementors§

Source§

impl Effect for FeedbackEffect

Source§

const OPERATION: &'static str = "feedback.compose"

Source§

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

§

impl Effect for NoEffect

§

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