pub struct ActionDecl<R: Resource> { /* private fields */ }Expand description
One mutation offered by name: a Declaration of the resource R,
whose fields it derefs to.
Implementations§
Source§impl<R: Resource> ActionDecl<R>
impl<R: Resource> ActionDecl<R>
Sourcepub fn edit_asking<V>(
id: &'static str,
label: impl Into<String>,
param: &'static str,
description: &'static str,
make: impl Fn(V) -> Edit<R> + Send + Sync + 'static,
) -> Selfwhere
V: DeserializeOwned + JsonSchema,
pub fn edit_asking<V>(
id: &'static str,
label: impl Into<String>,
param: &'static str,
description: &'static str,
make: impl Fn(V) -> Edit<R> + Send + Sync + 'static,
) -> Selfwhere
V: DeserializeOwned + JsonSchema,
A field edit whose one value its caller supplies, offered as the
action id labelled label: the parameter param (described by
description, typed by V’s schema) becomes the edit make(value).
What a row offers when the edit is bound to it but its value is not
(“Rename playlist”, “Add a song to this playlist”).
Sourcepub fn edit(id: &'static str, label: impl Into<String>, edit: Edit<R>) -> Self
pub fn edit(id: &'static str, label: impl Into<String>, edit: Edit<R>) -> Self
The field edit edit offered as the action id labelled label,
its value bound: what a place or a live row offers (“Use Proton for
Adobe Reader”), checked and recorded as the edit itself.
pub fn new( id: &'static str, label: impl Into<String>, params: Vec<ActionParam>, build: impl Fn(&ActionArgs, i64) -> Result<R::Action, String> + Send + Sync + 'static, ) -> Self
Sourcepub fn with_arguments(&self, arguments: Map<String, Value>) -> Invoke<R>
pub fn with_arguments(&self, arguments: Map<String, Value>) -> Invoke<R>
This action with arguments as a caller sent them over a call that names the action by
its id: what a dispatch hands the record, which binds them as it binds any.
Sourcepub fn into_declaration(self) -> Declaration
pub fn into_declaration(self) -> Declaration
The declaration, of whichever resource.
Sourcepub fn build_action(
&self,
args: &ActionArgs,
now_ms: i64,
) -> Result<R::Action, String>
pub fn build_action( &self, args: &ActionArgs, now_ms: i64, ) -> Result<R::Action, String>
The action it builds from args at now_ms.
Sourcepub fn refining(self) -> Self
pub fn refining(self) -> Self
Mark a bound edit as refining the resource’s declared action of the
same id (bind_declaration).
Sourcepub fn for_audience(self, audience: Audience) -> Self
pub fn for_audience(self, audience: Audience) -> Self
Declare who listings offer it to (tilo_actions::Audience), as
#[action(audience = ..)] declares it for a verb: a bound edit that
names entries by path is for agents and scripts, not a row a person
picks.
Sourcepub fn tagged(self, tag: impl Into<String>) -> Self
pub fn tagged(self, tag: impl Into<String>) -> Self
Tag the action’s contract (ContextRequirement::Caret.tag(), an
incremental-text declaration) for the callers that read it.
pub fn describe(self, description: impl Into<String>) -> Self
Sourcepub fn returns(self, result: ResultSpec) -> Self
pub fn returns(self, result: ResultSpec) -> Self
Declare what the action answers its caller with (an outline of the state it left), which the hosting surface supplies after it applies.
Sourcepub fn of_kind(self, kind: ActionKind) -> Self
pub fn of_kind(self, kind: ActionKind) -> Self
Set what the action is able to do.
Sourcepub fn below_field(self, field: &'static str) -> Self
pub fn below_field(self, field: &'static str) -> Self
Place the action below the one field it writes.
pub fn destructive(self) -> Self
Sourcepub fn writing(self, units: Vec<String>) -> Self
pub fn writing(self, units: Vec<String>) -> Self
The units the action writes, as the surface lists them
(crate::footprint).
Sourcepub fn answering(self) -> Self
pub fn answering(self) -> Self
Answer the caller with what the action made, from
Resource::answer.
Methods from Deref<Target = Declaration>§
Sourcepub fn shown_label(&self) -> String
pub fn shown_label(&self) -> String
What a person reads it by now, in their language.
Sourcepub fn shown_params(&self) -> Vec<ActionParam>
pub fn shown_params(&self) -> Vec<ActionParam>
Its parameters, each called what the person reads it by where its
catalogue has a word for it (crate::label::titled).
Trait Implementations§
Source§impl<R: Resource> AsRef<Declaration> for ActionDecl<R>
impl<R: Resource> AsRef<Declaration> for ActionDecl<R>
Source§fn as_ref(&self) -> &Declaration
fn as_ref(&self) -> &Declaration
Source§impl<R: Resource> Clone for ActionDecl<R>
impl<R: Resource> Clone for ActionDecl<R>
Source§impl<R: Resource> Deref for ActionDecl<R>
impl<R: Resource> Deref for ActionDecl<R>
Source§type Target = Declaration
type Target = Declaration
Source§fn deref(&self) -> &Declaration
fn deref(&self) -> &Declaration
Source§impl<R: Resource> DerefMut for ActionDecl<R>
impl<R: Resource> DerefMut for ActionDecl<R>
Source§fn deref_mut(&mut self) -> &mut Declaration
fn deref_mut(&mut self) -> &mut Declaration
Auto Trait Implementations§
impl<R> !RefUnwindSafe for ActionDecl<R>
impl<R> !UnwindSafe for ActionDecl<R>
impl<R> Forget for ActionDecl<R>
impl<R> Freeze for ActionDecl<R>
impl<R> Move for ActionDecl<R>
impl<R> Send for ActionDecl<R>
impl<R> Sync for ActionDecl<R>
impl<R> Unpin for ActionDecl<R>
impl<R> UnsafeUnpin for ActionDecl<R>
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