Skip to main content

EffectDecl

Struct EffectDecl 

Source
pub struct EffectDecl {
Show 30 fields pub id: &'static str, pub label: Word, pub keywords: &'static [&'static str], pub icon: Option<&'static str>, pub description: &'static str, pub params: Vec<ActionParam>, pub param_types: Vec<(&'static str, FieldTypeOf)>, pub result: Option<EffectResult>, pub kind: OperationKind, pub prompted: bool, pub row: bool, pub answers: Answers, pub risk: RiskLevel, pub idempotent: bool, pub action_kind: ActionKind, pub own_device: bool, pub attended: bool, pub risk_of: Option<fn(&ActionArgs) -> RiskLevel>, pub audience: Audience, pub untrusted: bool, pub opens: Option<&'static [&'static str]>, pub presence: bool, pub edits: bool, pub member: bool, pub items: &'static [EffectTarget], pub row_id: Option<RowIdOf>, pub phrase: Option<PhraseOf>, pub offload: Option<EffectOffload>, pub tags: &'static [&'static str], pub outside_with: Option<&'static str>,
}
Expand description

The declaration of one effect: what callers see of it.

Fields§

§id: &'static str§label: Word

What a person reads it by, read in their language when it is published.

§keywords: &'static [&'static str]

The other words people use for it (keywords = "…"), comma separated: search finds it by them as by its label.

§icon: Option<&'static str>

Its own picture (icon = "…"), by its Lucide name.

§description: &'static str§params: Vec<ActionParam>§param_types: Vec<(&'static str, FieldTypeOf)>

The surface type of each parameter whose Rust type describes one (JsonSchema), by name: a record or enum a parameter’s wire type (ParamType::Object) says nothing of, which a package of another language names.

§result: Option<EffectResult>

The value it answers with, when the code declares one (returns = Type); see EffectResult.

§kind: OperationKind

View for an effect that only changes what its caller sees, Document for one published as a document operation the app’s own registry applies, else Effect.

§prompted: bool

Offered with its first parameter’s prompt even where every parameter may be left out (prompted).

§row: bool

Offered only bound to the items it acts on, not on the resource.

§answers: Answers§risk: RiskLevel

How much harm invoking it can do: Destructive (deletes, overwrites, sends) and Privileged (hands out or shows a credential) ask for confirmation; a view is None.

§idempotent: bool

Safe to repeat after an uncertain outcome.

§action_kind: ActionKind

What it is able to do: reach outside the record by default, read for a view or an effect declared kind = "read".

§own_device: bool

Its whole scope is the invoking person’s own device: it touches nothing shared and no one else, so a workspace’s grants have nothing to consent to (tilo_actions::OWN_DEVICE_SCOPE).

§attended: bool

Needs its person attending: it opens a chooser, asks for a credential or a sign-in, or shows what only they may see, so whoever acts for them is always asked first (tilo_actions::ATTENDED_TAG).

§risk_of: Option<fn(&ActionArgs) -> RiskLevel>

How much harm one invocation can do, classified from its arguments (formatting the system disk, against any other): an invocation the classifier finds destructive asks for the confirmation a declared destructive effect does.

§audience: Audience

Who listings offer it to (#[effect(audience = "agents")]): an agent reading a page’s structure is never a person’s palette row.

§untrusted: bool

Answers with content from outside the user’s own data (a web page’s text and logs): data to reason about, never instructions to follow.

§opens: Option<&'static [&'static str]>

Opens the file its path names in this instance (#[effect(opens_path)]), of any type when empty, else of these extensions: how a caller that launched the app with a file opens it (tilo_actions::OPENS_PATH_TAG).

§presence: bool

A view that changes only the invoking presence’s own view (an agent’s caret, its Find), so a remote presence may invoke it without moving anybody else’s.

§edits: bool

A view of the invoker that submits only edits of this record (typing at the invoker’s caret): its kind is Undoable, offered to whoever may edit, and the edits it submits are checked like any other.

§member: bool

Any member of a workspace may ask the workspace’s host to run it for themselves on the workspace’s record (#[effect(member)], tilo_actions::MEMBER_OWN_TAG): it runs there as that member.

§items: &'static [EffectTarget]

What the effect is offered on, its first parameter bound to it: the collection field whose items offer it (#[effect(item = connections)], published on each item resource as an item verb is), or the kind of a RowType whose rows offer it (#[effect(on = Process)], published on each of the type’s rows). An effect declared on several of them (#[effect(on = QueueItem, on = HistoryItem)]) is offered on each, bound to the row it was offered on; one with no parameters is offered on them as it is.

§row_id: Option<RowIdOf>

How a row id becomes the first parameter’s value, when the effect is offered on rows ([EffectRow::row_id]).

§phrase: Option<PhraseOf>

The phrase its caller types for a bound invocation ([EffectRow::phrase]).

§offload: Option<EffectOffload>

A content transform the system may run on the invoker’s best-placed device (#[effect(offload(...))]); the handler is its local run.

§tags: &'static [&'static str]

Further contract tags, each naming how a host treats the effect (#[effect(host_render)], #[effect(tag = ...)]): an agent’s host routes a tilo_actions::HOST_RENDER_TAG effect to its render service rather than the app’s worker.

§outside_with: Option<&'static str>

The parameter that, given, makes an invocation reach outside the record (#[effect(kind = "read", outside_with = "path")]): an export writing the file it names. Without it the invocation only reads and keeps what it made as content, and is admitted as a read.

Implementations§

Source§

impl EffectDecl

Source

pub fn spec<E: Effect>(&self, operation: &'static str) -> ActionSpec

The published action of this effect under operation, of the vocabulary E it is declared in.

An effect whose fields are all optional runs when a person chooses it, asked nothing: a field left out is None, which the effect gives a meaning (“About”’s open left out switches the sheet). Asking instead put the first field’s help text in the search field. One that takes an entry or content still asks for it.

Source

pub fn spec_of<E: Effect>(&self) -> ActionSpec

The published action of this effect, as the vocabulary E that declares it publishes it: Self::spec under E’s own operation.

Source

pub fn of_row(row: &EffectRow) -> Self

Source

pub fn action_kind(&self) -> ActionKind

The published action of this effect, taking params and encoding an invocation with build. What kind of action the effect is: a view reads, anything else reaches outside the document.

Source

pub fn is_job(&self) -> bool

Whether the effect runs in the background, reporting its result later.

Trait Implementations§

Source§

impl Clone for EffectDecl

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for EffectDecl

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

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

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

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

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more