pub struct ActionSpec { /* private fields */ }Expand description
One action a resource exports to the palette: an ActionType bound to
the Target it acts on. Small: the type is shared, so a resource of
ten thousand items holds each of its types once.
It reads as its type (spec.id, spec.contract).
Implementations§
Source§impl ActionSpec
impl ActionSpec
Sourcepub fn prefilled(&mut self, name: &str, value: Value)
pub fn prefilled(&mut self, name: &str, value: Value)
ActionType::prefilled on the action this spec publishes: this
item’s, copied first when other items share the type.
Source§impl ActionSpec
impl ActionSpec
Sourcepub fn with_param_choices(
self,
name: &str,
choices: impl IntoIterator<Item = Cow<'static, str>>,
) -> Self
pub fn with_param_choices( self, name: &str, choices: impl IntoIterator<Item = Cow<'static, str>>, ) -> Self
This action with name’s accepted values narrowed to choices: the
sessions a greeter offers now, the challenge waiting for an answer. Its
other parameters, operation and contract stay as declared, and an
unknown name leaves it as it is.
Source§impl ActionSpec
impl ActionSpec
Sourcepub fn without_carried(&mut self, refused: &[&str])
pub fn without_carried(&mut self, refused: &[&str])
Take the actions refused names out of what this action says it carries
(Self::carrying): out of the ids the schemas of its parameters name. Whoever
lists a resource to a caller calls it with the actions it drops for them, or lists
to them as not allowed, so a carrier names to that caller only what their own call
of it is not refused for. An action that carries none, or names none of them, stays
as it is and keeps the schema it shares.
Source§impl ActionSpec
impl ActionSpec
Sourcepub fn action_type(&self) -> &Arc<ActionType> ⓘ
pub fn action_type(&self) -> &Arc<ActionType> ⓘ
The type this spec binds: what every resource offering the action
shares. Bind it to other targets with ActionType::bind.
Sourcepub fn type_mut(&mut self) -> &mut ActionType
pub fn type_mut(&mut self) -> &mut ActionType
This spec’s type, to change: copied first when other specs share it, so a change to one item’s action never reaches another’s.
Sourcepub fn input(&self) -> ActionInput<'_>
pub fn input(&self) -> ActionInput<'_>
How the palette collects this action’s input.
Sourcepub fn encode_immediate(&self) -> Option<Arc<EncodedAction>>
pub fn encode_immediate(&self) -> Option<Arc<EncodedAction>>
The action an Immediate spec fires, or
None for one that takes input or is deferred. An action declared
with what it acts on in its builder was encoded once, when declared;
one bound to a target is encoded for it now.
Sourcepub fn published_encoding(&self) -> Option<&Arc<EncodedAction>>
pub fn published_encoding(&self) -> Option<&Arc<EncodedAction>>
The encoding an Immediate spec already holds, when it was
encoded once and shared by every resource offering it; None for one built from its
target when it is invoked. Reads, never builds: validating a surface of ten thousand
items runs no action.
Sourcepub fn build_deferred(&self) -> Option<EncodedAction>
pub fn build_deferred(&self) -> Option<EncodedAction>
Run a Deferred spec’s builder, unchecked:
None for any other. Callers check the result’s type against the
declared one, as the API does.
Sourcepub fn run_by(self, provider: impl Into<String>) -> Self
pub fn run_by(self, provider: impl Into<String>) -> Self
This action as provider publishes and runs it: a view shows another
provider’s resource and binds its controls to that provider’s
actions. The view’s publisher never runs nor publishes it; its host
invokes it at provider, which admits and runs it as any caller’s.
Sourcepub fn run_as(self, run: RunBy) -> Self
pub fn run_as(self, run: RunBy) -> Self
Self::run_by as run says where the provider publishes it.
Sourcepub fn run_by_provider(&self) -> Option<&RunBy>
pub fn run_by_provider(&self) -> Option<&RunBy>
Where another provider than the resource’s publisher runs this
action (Self::run_by).
Sourcepub fn provider(&self) -> Option<&str>
pub fn provider(&self) -> Option<&str>
The provider that runs this action, when it is another than the
resource’s publisher (Self::run_by).
Sourcepub fn applied_as(
self,
kind: impl Into<String>,
label: impl Into<String>,
) -> Self
pub fn applied_as( self, kind: impl Into<String>, label: impl Into<String>, ) -> Self
Mark this action as applied as the enclosing resource of kind kind
(labelled label): a nested resource (a note’s rich-text body)
publishes its document actions re-encoded as the record’s field
edit, so the record’s surface, permissions and history decide them.
Sourcepub fn history_context(
&self,
id: &str,
kind: &str,
label: &str,
) -> ActionContext
pub fn history_context( &self, id: &str, kind: &str, label: &str, ) -> ActionContext
The history entry of invoking this action on the resource id, of
kind kind and labelled label. It names that resource, of the kind
whose action the value is: for a nested resource’s action, the
enclosing resource’s kind and label, with the nested resource kept as
a NESTED_RESOURCE_FACET facet. Naming the nested kind made the
change claim a kind its app’s surface does not describe, so every
receiver held it and the signer refused it.
Sourcepub fn fixed_invocation_encoding(&self) -> Option<&EncodedAction>
pub fn fixed_invocation_encoding(&self) -> Option<&EncodedAction>
Borrow the actual fixed encoding used by the typed invocation builder.
None means the builder is opaque, even if its palette input is Immediate.
This is comparison data, never permission to invoke an action.
Sourcepub fn has_continuation_identity(&self) -> bool
pub fn has_continuation_identity(&self) -> bool
Whether a provider installed continuation evidence. An installed provider returning unknown is distinct from having no provider.
Sourcepub fn deferred_invocation_type(&self) -> Option<&str>
pub fn deferred_invocation_type(&self) -> Option<&str>
Declared type of an explicit deferred invocation. This is inert metadata, never an encoding or authorization to execute the retained builder.
Sourcepub fn validate_json(
&self,
supplied: &Map<String, Value>,
) -> Result<(), ArgError>
pub fn validate_json( &self, supplied: &Map<String, Value>, ) -> Result<(), ArgError>
Strict argument validation without invoking an encoder.
Sourcepub fn bound(&self) -> &[(String, Value)]
pub fn bound(&self) -> &[(String, Value)]
The arguments this action fixes (Self::with_bound), by name.
Sourcepub fn with_bound(self, values: Vec<(String, Value)>) -> Self
pub fn with_bound(self, values: Vec<(String, Value)>) -> Self
This action fixing values: a declaration offered on the item it
acts on (“rename this album”), its item parameter bound and left
out of Self::params. A caller that passes a bound argument anyway
is heard as leaving it out when it names the bound value (an item’s
id also in a longer form of the item’s address, sheets/<id>), and
refused, naming the bound value, when it names another: the action
acts on its item only.
Sourcepub fn stating_bound(self, name: &str, description: &str) -> Self
pub fn stating_bound(self, name: &str, description: &str) -> Self
The bound argument name, stated in what this action publishes: an
optional parameter whose only accepted value is the one this action
is bound to, described as description. A row of a person’s own
window invokes it without naming anything — it is bound here — while
a caller reading the published action learns which item this one is
bound to, and answers that one among several a page or a list
publishes side by side. Calling it again for another name states that
one beside the first, so a row can state every value it is bound to.
Nothing an invocation carries changes: the value invocations run is
still the bound one (Self::with_bound), and naming it is how a
caller says which of several bound rows it means.
Sourcepub fn deferred(
id: impl Into<String>,
label: impl Into<String>,
locus: ExecutionLocus,
type_id: impl Into<String>,
build: impl Fn() -> EncodedAction + Send + Sync + 'static,
) -> Self
pub fn deferred( id: impl Into<String>, label: impl Into<String>, locus: ExecutionLocus, type_id: impl Into<String>, build: impl Fn() -> EncodedAction + Send + Sync + 'static, ) -> Self
A document operation whose no-argument builder runs only at execution. Both invocation input modes share this one closure; construction never runs it.
Sourcepub fn deferred_on(
id: impl Into<String>,
label: impl Into<String>,
locus: ExecutionLocus,
type_id: impl Into<String>,
build: impl Fn(&Target) -> EncodedAction + Send + Sync + 'static,
) -> Self
pub fn deferred_on( id: impl Into<String>, label: impl Into<String>, locus: ExecutionLocus, type_id: impl Into<String>, build: impl Fn(&Target) -> EncodedAction + Send + Sync + 'static, ) -> Self
deferred for a type shared by many targets: the
builder is given the target of the spec being invoked.
Sourcepub fn deferred_operation(
id: impl Into<String>,
label: impl Into<String>,
kind: OperationKind,
type_id: impl Into<String>,
build: impl Fn() -> EncodedAction + Send + Sync + 'static,
) -> Self
pub fn deferred_operation( id: impl Into<String>, label: impl Into<String>, kind: OperationKind, type_id: impl Into<String>, build: impl Fn() -> EncodedAction + Send + Sync + 'static, ) -> Self
An effect/view operation with deferred no-argument encoding.
Sourcepub fn immediate<A>(
id: impl Into<String>,
label: impl Into<String>,
type_id: impl Into<String>,
action: &A,
) -> Result<Self, ActionError>
pub fn immediate<A>( id: impl Into<String>, label: impl Into<String>, type_id: impl Into<String>, action: &A, ) -> Result<Self, ActionError>
An action that fires immediately. type_id must match the app’s
registry registration for A.
Projects to zero parameters: invoking it externally with an empty argument set yields exactly the pre-encoded action the palette fires.
§Errors
Returns ActionError when action cannot be encoded.
Sourcepub fn immediate_encoded(
id: impl Into<String>,
label: impl Into<String>,
locus: ExecutionLocus,
encoded: EncodedAction,
) -> Self
pub fn immediate_encoded( id: impl Into<String>, label: impl Into<String>, locus: ExecutionLocus, encoded: EncodedAction, ) -> Self
An action that fires immediately, from an EncodedAction the caller
already holds.
immediate is the usual API — it takes a typed
action and reads its locus — but a caller that has
only the encoded form (a stored action, a fixture, one that arrived over
a wire) has no typed value to hand it. Projects to zero parameters, the
same as immediate.
Sourcepub fn prompted_param(
id: impl Into<String>,
label: impl Into<String>,
param: ActionParam,
placeholder: impl Into<String>,
locus: ExecutionLocus,
build: impl Fn(&str) -> EncodedAction + Send + Sync + 'static,
) -> Self
pub fn prompted_param( id: impl Into<String>, label: impl Into<String>, param: ActionParam, placeholder: impl Into<String>, locus: ExecutionLocus, build: impl Fn(&str) -> EncodedAction + Send + Sync + 'static, ) -> Self
An action that first collects a free-text argument, then builds its
encoded action from it, the argument being the parameter param:
ActionParam::required("title", ParamType::Text, "The note's new title"). The name and description are what an agent reads, and the
description is also the palette’s prompt.
The projection and the palette share the same build closure, so an
external invocation and the on-screen affordance produce the
byte-identical EncodedAction. Callers that hold the typed text
find where it goes with Self::prompt_param, never by name. Name the
parameter for what it is (title, name, comment): an agent reads
it, and the generic PROMPTED_PARAM tells it nothing.
Sourcepub fn prompted_param_on(
id: impl Into<String>,
label: impl Into<String>,
param: ActionParam,
placeholder: impl Into<String>,
locus: ExecutionLocus,
build: impl Fn(&Target, &str) -> EncodedAction + Send + Sync + 'static,
) -> Self
pub fn prompted_param_on( id: impl Into<String>, label: impl Into<String>, param: ActionParam, placeholder: impl Into<String>, locus: ExecutionLocus, build: impl Fn(&Target, &str) -> EncodedAction + Send + Sync + 'static, ) -> Self
prompted_param for a type shared by many
targets: the builder is given the target of the spec being invoked.
Sourcepub fn prompt_param(&self) -> Option<&str>
pub fn prompt_param(&self) -> Option<&str>
The name of the parameter the typed text of a prompted action goes
into, or None for an action that collects no text. The one place a
caller holding the text of a prompt (the palette, a broker request, a
continuation) learns where it belongs.
Sourcepub fn entry_param(&self) -> Option<&str>
pub fn entry_param(&self) -> Option<&str>
The parameter one line of typed text fills, when the action is a
capture: it declares one (ActionParam::entry).
Sourcepub fn prompt_arguments(&self, text: &str) -> Option<Map<String, Value>>
pub fn prompt_arguments(&self, text: &str) -> Option<Map<String, Value>>
text as this action’s typed arguments, when it is a prompted action.
Sourcepub fn operation<T>(
id: impl Into<String>,
label: impl Into<String>,
kind: OperationKind,
type_id: impl Into<String>,
payload: &T,
) -> Result<Self, ActionError>where
T: Serialize,
pub fn operation<T>(
id: impl Into<String>,
label: impl Into<String>,
kind: OperationKind,
type_id: impl Into<String>,
payload: &T,
) -> Result<Self, ActionError>where
T: Serialize,
An immediate effect or view operation owned by the application.
§Errors
Returns ActionError::Encode if payload fails to serialize.
Sourcepub fn prompted_operation(
id: impl Into<String>,
label: impl Into<String>,
prompt: impl Into<String>,
placeholder: impl Into<String>,
kind: OperationKind,
type_id: impl Into<String>,
build: impl Fn(&str) -> EncodedAction + Send + Sync + 'static,
) -> Self
pub fn prompted_operation( id: impl Into<String>, label: impl Into<String>, prompt: impl Into<String>, placeholder: impl Into<String>, kind: OperationKind, type_id: impl Into<String>, build: impl Fn(&str) -> EncodedAction + Send + Sync + 'static, ) -> Self
A prompted effect or view operation owned by the application.
Sourcepub fn with_immediate(self, encoded: EncodedAction) -> Self
pub fn with_immediate(self, encoded: EncodedAction) -> Self
Fire encoded at once when a person chooses the action (the palette,
a menu, the shortcut), asking nothing; a caller that passes arguments
still binds them against its parameters. For a typed action whose
arguments all have a meaning when left out (open search, unnarrowed).
Sourcepub fn with_immediate_per_target(self) -> Self
pub fn with_immediate_per_target(self) -> Self
Fire at once when a person chooses the action, asking nothing, encoded per invocation
from its target: with_immediate for a type shared by many
targets. For a typed action whose parameters are all optional, each with a meaning when
left out; a caller that passes arguments still binds them against its parameters. An
action with a required parameter keeps asking for it.
Sourcepub fn with_continuation_identity(
self,
resolver: impl for<'a> Fn(ContinuationQuery<'a>) -> Option<ContinuationEvidence> + Send + Sync + 'static,
) -> Self
pub fn with_continuation_identity( self, resolver: impl for<'a> Fn(ContinuationQuery<'a>) -> Option<ContinuationEvidence> + Send + Sync + 'static, ) -> Self
Opt one action into inert, provider-defined continuation evidence.
Sourcepub fn continuation_identity(
&self,
query: ContinuationQuery<'_>,
) -> Option<ContinuationEvidence>
pub fn continuation_identity( &self, query: ContinuationQuery<'_>, ) -> Option<ContinuationEvidence>
Resolve comparison-only evidence for the exact input or draft domain. A mismatched response variant is rejected as unsupported.
Sourcepub fn prompted_content(
id: impl Into<String>,
label: impl Into<String>,
prompt: impl Into<String>,
placeholder: impl Into<String>,
locus: ExecutionLocus,
build: impl Fn(&str) -> EncodedAction + Send + Sync + 'static,
) -> Self
pub fn prompted_content( id: impl Into<String>, label: impl Into<String>, prompt: impl Into<String>, placeholder: impl Into<String>, locus: ExecutionLocus, build: impl Fn(&str) -> EncodedAction + Send + Sync + 'static, ) -> Self
An action whose one argument is the content hash of bytes this
machine already holds, rather than typed words — a separate
constructor (not a parameter on Self::prompted_param) so every
existing action keeps saying exactly what it said.
Sourcepub fn prompted_content_on(
id: impl Into<String>,
label: impl Into<String>,
prompt: impl Into<String>,
placeholder: impl Into<String>,
locus: ExecutionLocus,
build: impl Fn(&Target, &str) -> EncodedAction + Send + Sync + 'static,
) -> Self
pub fn prompted_content_on( id: impl Into<String>, label: impl Into<String>, prompt: impl Into<String>, placeholder: impl Into<String>, locus: ExecutionLocus, build: impl Fn(&Target, &str) -> EncodedAction + Send + Sync + 'static, ) -> Self
prompted_content for a type shared by many
targets: the builder is given the target of the spec being invoked.
Sourcepub fn with_keywords<S: Into<String>>(
self,
keywords: impl IntoIterator<Item = S>,
) -> Self
pub fn with_keywords<S: Into<String>>( self, keywords: impl IntoIterator<Item = S>, ) -> Self
Declare the other words people use for this action
([Self::keywords]): plain words, one phrase each, no repetition of
the label.
Sourcepub fn with_did(self, did: impl Into<String>) -> Self
pub fn with_did(self, did: impl Into<String>) -> Self
Declare what the action did, said after who did it ([Self::did]):
“showed this on the canvas”, “added a subtask”.
Sourcepub fn with_icon(self, icon: impl Into<String>) -> Self
pub fn with_icon(self, icon: impl Into<String>) -> Self
Give the action its own picture ([Self::icon]), by its Lucide name.
pub fn with_description(self, description: impl Into<String>) -> Self
Sourcepub fn with_state(self, state: ActionState) -> Self
pub fn with_state(self, state: ActionState) -> Self
Show state on the action’s row (ActionState): publish the
action anew when it changes.
pub fn with_contract(self, contract: ActionContract) -> Self
Sourcepub fn destructive(self) -> Self
pub fn destructive(self) -> Self
A deletion: its kind is
deletion_kind, and the tags the spec
already carries settle its confirmation — asked with a click unless a
compensated undo says Undo takes it back.
Sourcepub fn for_audience(self, audience: Audience) -> Self
pub fn for_audience(self, audience: Audience) -> Self
List this action for audience only (Audience).
Recorded in the contract’s tags, so the audience crosses every
boundary the inert contract does. Call after
with_contract, which replaces the tags.
Sourcepub fn reads_document(self) -> Self
pub fn reads_document(self) -> Self
Declare this read-only action as the one that answers, with no
arguments, the first page of the app’s open document. Recorded as
DOCUMENT_READ_TAG, so a caller that just
opened a file finds it in the directory. Call after
with_contract, which replaces the tags.
Sourcepub fn reads_resource(self) -> Self
pub fn reads_resource(self) -> Self
Declare this view as a read of what its record holds that takes
arguments (a version, a review of one): recorded as
RESOURCE_READ_TAG, it moves nothing, anyone
who may read the record may run it, and it discloses the record to
them. Call after with_contract, which replaces
the tags.
Sourcepub fn opens_path(self, extensions: &[&str]) -> Self
pub fn opens_path(self, extensions: &[&str]) -> Self
Declare this action as the one that opens the file its path
parameter names in this app instance, of any type when extensions
is empty, else of those (lowercase, no dot). Recorded as
OPENS_PATH_TAG, so a caller that launches
the app with a file opens it here, and never through an action
that only happens to take a path. Call after
with_contract, which replaces the tags.
Sourcepub fn audience(&self) -> Audience
pub fn audience(&self) -> Audience
Who this action is listed for. See for_audience.
Sourcepub fn reaches_people(&self) -> bool
pub fn reaches_people(&self) -> bool
Whether people’s listings (the palette, menus) offer it.
Sourcepub fn reaches_agents(&self) -> bool
pub fn reaches_agents(&self) -> bool
Whether agents’ listings offer it.
Sourcepub fn takes_a_row_answer(&self) -> bool
pub fn takes_a_row_answer(&self) -> bool
Whether a row a person picks can supply what it asks for: nothing, or the one line its prompt collects (a name, a number, a date). One that needs several arguments, or a list, an object or another resource’s address, is taken by callers that name them (agents, scripts, the controls bound to where the person is), never from a row.
Sourcepub fn carrying(self) -> Self
pub fn carrying(self) -> Self
Declare that this action carries the resource’s other actions (a
generic typed edit, a group of edits): history records the actions
it carried, never this one. The contract advertises
CARRIER_TAG, so whoever decides for it or words
it for a person reads what it carries. Call after
with_contract, which replaces the tags.
Sourcepub fn carries_actions(&self) -> bool
pub fn carries_actions(&self) -> bool
Whether this action carries the resource’s other actions. See
Self::carrying.
Sourcepub fn with_risk(
self,
classify: impl Fn(&ActionArgs) -> RiskLevel + Send + Sync + 'static,
) -> Self
pub fn with_risk( self, classify: impl Fn(&ActionArgs) -> RiskLevel + Send + Sync + 'static, ) -> Self
Classify each invocation’s risk from its bound arguments, for an action
whose consequence depends on them (a generic edit whose value may
delete). Whenever the classified risk
requires confirmation, the host
asks for exactly the confirmation a declared
destructive action gets; otherwise the action
runs directly. The contract advertises
ARGUMENT_RISK_TAG so callers that cannot
classify know to expect it.
Sourcepub fn with_risk_on(
self,
classify: impl Fn(&Target, &ActionArgs) -> RiskLevel + Send + Sync + 'static,
) -> Self
pub fn with_risk_on( self, classify: impl Fn(&Target, &ActionArgs) -> RiskLevel + Send + Sync + 'static, ) -> Self
with_risk for a type shared by many targets: the
classifier is given the target of the spec being invoked.
Sourcepub fn with_need_of(
self,
classify: impl Fn(&ActionArgs) -> ActionNeed + Send + Sync + 'static,
) -> Self
pub fn with_need_of( self, classify: impl Fn(&ActionArgs) -> ActionNeed + Send + Sync + 'static, ) -> Self
Classify what each invocation is from its bound arguments, for an
action whose consequence depends on them (a generic edit: a reply
writes only the comments, a deletion changes the document). The
declared ActionContract::kind and ActionContract::field stay
the least any invocation is, which is what a host offers the action
under; every check that admits an invocation asks
need_for too.
Sourcepub fn need_for_args(&self, args: &ActionArgs) -> ActionNeed
pub fn need_for_args(&self, args: &ActionArgs) -> ActionNeed
What one invocation with these bound arguments is: the classifier’s verdict, else the declared contract’s.
Sourcepub fn need_for(
&self,
json: Option<&Map<String, Value>>,
argument: Option<&str>,
) -> ActionNeed
pub fn need_for( &self, json: Option<&Map<String, Value>>, argument: Option<&str>, ) -> ActionNeed
What one invocation is, by the value it carries: json, or the
palette’s and legacy text API’s argument (typed JSON behind
ARGUMENTS_JSON_PREFIX, one line of
text for the primary parameter, or nothing). Arguments that do not
bind build no action, so they are what the declaration says.
Sourcepub fn with_undo_of(
self,
classify: impl Fn(&ActionArgs) -> bool + Send + Sync + 'static,
) -> Self
pub fn with_undo_of( self, classify: impl Fn(&ActionArgs) -> bool + Send + Sync + 'static, ) -> Self
Decide per invocation whether Undo takes it back, for an action that
carries others (a group: Undo takes it back only when it takes back
every member). Without it, the contract’s
can_be_undone decides.
Sourcepub fn undoable_for(&self, args: &ActionArgs) -> bool
pub fn undoable_for(&self, args: &ActionArgs) -> bool
Whether Undo takes back one invocation with these bound arguments.
Sourcepub fn risk_for(&self, args: &ActionArgs) -> RiskLevel
pub fn risk_for(&self, args: &ActionArgs) -> RiskLevel
The risk of one invocation: the classifier’s verdict for these
arguments, or the declared ActionContract::risk.
Sourcepub fn confirmation_for_args(&self, args: &ActionArgs) -> ConfirmationPolicy
pub fn confirmation_for_args(&self, args: &ActionArgs) -> ConfirmationPolicy
Sourcepub fn confirmation_for_json(
&self,
supplied: &Map<String, Value>,
) -> ConfirmationPolicy
pub fn confirmation_for_json( &self, supplied: &Map<String, Value>, ) -> ConfirmationPolicy
confirmation_for_args for arguments
that arrived as JSON. Arguments that do not bind cannot build an
action at all, so they get the declared policy.
Sourcepub fn confirmation_for_argument(
&self,
argument: Option<&str>,
) -> ConfirmationPolicy
pub fn confirmation_for_argument( &self, argument: Option<&str>, ) -> ConfirmationPolicy
confirmation_for_args for the palette
and legacy text API: typed JSON behind
ARGUMENTS_JSON_PREFIX, one line of
text for the primary parameter, or nothing.
pub fn privileged(self) -> Self
Sourcepub fn of_kind(self, kind: ActionKind) -> Self
pub fn of_kind(self, kind: ActionKind) -> Self
Set what the action is able to do, as the declaration sees it. See
ActionContract::kind.
Sourcepub fn with_need(self, need: ActionNeed) -> Self
pub fn with_need(self, need: ActionNeed) -> Self
Set the field the action writes, and its kind unless the declaration
named one (of_kind), which a need does not overrule.
Sourcepub fn below_field(self, field: impl Into<String>) -> Self
pub fn below_field(self, field: impl Into<String>) -> Self
Place the action below the one field it writes. See
ActionContract::field.
pub fn execution(self, execution: ExecutionMode) -> Self
pub fn returns(self, result: ResultSpec) -> Self
Sourcepub fn rewrapped(
self,
wrapped_type: &str,
wrap: impl Fn(EncodedAction) -> EncodedAction + Send + Sync + 'static,
) -> Self
pub fn rewrapped( self, wrapped_type: &str, wrap: impl Fn(EncodedAction) -> EncodedAction + Send + Sync + 'static, ) -> Self
This document action as another resource carries it: every action it
builds passes through wrap, which re-encodes it as the action of the
resource that contains this one (a rich-text edit becomes the note’s
edit of its body, registered under wrapped_type). Parameters,
kind, field, risk and confirmation stay this action’s. A builder’s
refusal passes through unchanged. An effect or view operation is
returned as it is: it writes nothing to wrap.
Sourcepub fn routed(
self,
operation_type: &str,
wrap: impl Fn(EncodedAction) -> EncodedAction + Send + Sync + 'static,
) -> Self
pub fn routed( self, operation_type: &str, wrap: impl Fn(EncodedAction) -> EncodedAction + Send + Sync + 'static, ) -> Self
This document action, carried out on another document than the one
its resource’s host holds (the person’s own record, a settings
section): published as an effect operation of operation_type whose
value is wrap of the encoded action, which the host answering
operation_type applies to that document. Parameters, kind,
permission, risk and confirmation stay this action’s, and it is
tagged crate::ROUTED_CHANGE_TAG: a change of a document still. An
effect or view operation is returned as it is.
Sourcepub fn params(&self) -> &[ActionParam]
pub fn params(&self) -> &[ActionParam]
What an invocation of this action must carry. Empty for the nullary majority.
Part of the descriptor rather than something a caller discovers by trying: enumeration is all a caller that cannot see the screen has to work from, so an action whose parameters were not advertised would be un-invokable except by guesswork.
Sourcepub fn narrow_param(
&mut self,
name: &str,
narrow: impl FnOnce(&mut ActionParam),
)
pub fn narrow_param( &mut self, name: &str, narrow: impl FnOnce(&mut ActionParam), )
Narrow the parameter name this action declares for the entity it is
offered on: the values it takes there now, what it means there, the
bounds its state sets. A parameter the action does not declare is left
alone, so narrowing a spec an entity does not have the argument for is
no change rather than a panic.
Sourcepub fn build_args(
&self,
supplied: impl IntoIterator<Item = (String, ArgValue)>,
) -> Result<EncodedAction, ArgError>
pub fn build_args( &self, supplied: impl IntoIterator<Item = (String, ArgValue)>, ) -> Result<EncodedAction, ArgError>
Bind supplied against params and build the action.
Strict: a missing, unknown, wrong-typed or out-of-choice argument is
refused here, and the caller never receives an EncodedAction to
dispatch — so a bad call cannot become a partial mutation, because
nothing was ever handed to the executor.
Sourcepub fn build_json(
&self,
supplied: &Map<String, Value>,
) -> Result<EncodedAction, ArgError>
pub fn build_json( &self, supplied: &Map<String, Value>, ) -> Result<EncodedAction, ArgError>
build_args for arguments that arrived as JSON.
Sourcepub fn build_text(&self, text: &str) -> Option<EncodedAction>
pub fn build_text(&self, text: &str) -> Option<EncodedAction>
The palette input mode’s encoding for one typed text argument, exactly as a
prompted affordance builds it. None when this action collects no text.
Source§impl ActionSpec
impl ActionSpec
Sourcepub fn requires(self, requirement: ContextRequirement) -> Self
pub fn requires(self, requirement: ContextRequirement) -> Self
Declare a precondition on the invoker’s view. The operation stays at its stable address in every presence’s tree and in the published schema; the invoker’s tree refuses it when the precondition fails.
Sourcepub fn presence_view(self) -> Self
pub fn presence_view(self) -> Self
Declare that this View operation changes only the invoking presence’s own view, so a remote presence may invoke it.
Methods from Deref<Target = ActionType>§
Sourcepub fn bind(self: &Arc<Self>, target: Target) -> ActionSpec
pub fn bind(self: &Arc<Self>, target: Target) -> ActionSpec
This type bound to target: the action one item offers.
Trait Implementations§
Source§impl Clone for ActionSpec
impl Clone for ActionSpec
Source§impl Deref for ActionSpec
impl Deref for ActionSpec
Source§type Target = ActionType
type Target = ActionType
Source§fn deref(&self) -> &ActionType
fn deref(&self) -> &ActionType
Auto Trait Implementations§
impl !RefUnwindSafe for ActionSpec
impl !UnwindSafe for ActionSpec
impl Forget for ActionSpec
impl Freeze for ActionSpec
impl Move for ActionSpec
impl Send for ActionSpec
impl Sync for ActionSpec
impl Unpin for ActionSpec
impl UnsafeUnpin for ActionSpec
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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