pub struct ActionParam {
pub name: Str,
pub ty: ParamType,
pub required: bool,
pub entry: bool,
pub description: Str,
pub choices: Vec<Str>,
pub schema: Option<Arc<Value>>,
pub nullable: bool,
}Expand description
One typed parameter an action declares.
Fields§
§name: Str§ty: ParamType§required: boolWhether an invocation must supply it. An optional parameter’s default
belongs to the action and is stated in description — the surface does
not invent one.
entry: boolWhether one line of typed text fills this parameter, and the others
the words it says (title: Text (entry)). An action with one is
offered as a capture: a person types “call landlord fri 10am” and the
action’s own field types read the rest.
description: Str§choices: Vec<Str>When non-empty, the only values this parameter accepts.
This is what turns a prose list ("grayscale / sepia / invert") into
something a caller can read and something ActionArgs::bind can
enforce. A value outside the set is refused by name rather than
quietly falling through to a default.
schema: Option<Arc<Value>>JSON Schema fragment applied after the basic type check. This carries ranges, lengths, patterns, formats, item/object schemas, and defaults without growing a second incompatible validation vocabulary.
nullable: boolExplicitly permits JSON null. Optional means omitted; nullable means present with no value, and callers need to distinguish the two.
Implementations§
Source§impl ActionParam
impl ActionParam
Sourcepub const fn required(
name: &'static str,
ty: ParamType,
description: &'static str,
) -> Self
pub const fn required( name: &'static str, ty: ParamType, description: &'static str, ) -> Self
A required parameter with static strings — usable in a const.
Sourcepub const fn optional(
name: &'static str,
ty: ParamType,
description: &'static str,
) -> Self
pub const fn optional( name: &'static str, ty: ParamType, description: &'static str, ) -> Self
An optional parameter with static strings — usable in a const.
Sourcepub fn required_owned(
name: impl Into<Str>,
ty: ParamType,
description: impl Into<Str>,
) -> Self
pub fn required_owned( name: impl Into<Str>, ty: ParamType, description: impl Into<Str>, ) -> Self
A required parameter whose strings are built at runtime — what an app declaring parameters out of live document state needs.
Sourcepub fn optional_owned(
name: impl Into<Str>,
ty: ParamType,
description: impl Into<Str>,
) -> Self
pub fn optional_owned( name: impl Into<Str>, ty: ParamType, description: impl Into<Str>, ) -> Self
An optional parameter whose strings are built at runtime.
Sourcepub fn taking_entry(self) -> Self
pub fn taking_entry(self) -> Self
Have one line of typed text fill this parameter, and the parameters
the words say (ActionParam::entry).
Sourcepub fn with_choices<S: Into<Str>>(
self,
choices: impl IntoIterator<Item = S>,
) -> Self
pub fn with_choices<S: Into<Str>>( self, choices: impl IntoIterator<Item = S>, ) -> Self
Restrict this parameter to choices. Binding refuses anything else.
pub fn with_schema(self, schema: Value) -> Self
Sourcepub fn titled(self, title: impl Into<String>) -> Self
pub fn titled(self, title: impl Into<String>) -> Self
Call this parameter title where people read it (a form’s field, a
consent sheet’s row): its schema’s title, in the reader’s language.
Sourcepub fn described(self, title: impl Into<String>) -> Self
pub fn described(self, title: impl Into<String>) -> Self
Call this parameter title where people read it and describe it so:
what a catalogue says of a parameter of a declared action or effect,
read in the reader’s language.
Sourcepub fn with_default(self, value: Value) -> Self
pub fn with_default(self, value: Value) -> Self
Offer value in this parameter’s place: what the action’s own state
knows it would be (a calendar’s current colour), which a caller may
change. Its schema’s default, so a surface fills the field without
binding anything.
Retain an immutable schema already shared by the current type generation. Wire serialization and strict argument validation are unchanged.
Sourcepub fn taking_resource_kinds<I, S>(self, kinds: I) -> Self
pub fn taking_resource_kinds<I, S>(self, kinds: I) -> Self
Name the kinds of resource this ParamType::Resource parameter
takes, any one of them (a channel, a thread or a direct conversation), as the
RESOURCE_KINDS_ANNOTATION of its schema: what tells a grant that the step may reach
every one of them.
Sourcepub fn resource_kinds(&self) -> Vec<&str>
pub fn resource_kinds(&self) -> Vec<&str>
The kinds of resource this parameter takes, when it names several
(Self::taking_resource_kinds).
Sourcepub fn of_resource_kind(self, kind: impl Into<String>) -> Self
pub fn of_resource_kind(self, kind: impl Into<String>) -> Self
Name the kind of resource this ParamType::Resource parameter
takes (e.g. files.entry), as the RESOURCE_KIND_ANNOTATION of its
schema. Surfaces use it to offer the action on resources of that kind
and its sub-kinds.
Sourcepub fn with_labelled_choices<V: Into<Str>, L: Into<String>>(
self,
choices: impl IntoIterator<Item = (V, L)>,
) -> Self
pub fn with_labelled_choices<V: Into<Str>, L: Into<String>>( self, choices: impl IntoIterator<Item = (V, L)>, ) -> Self
Restrict this parameter to the first of each pair, each read as the
second (CHOICE_LABELS_ANNOTATION): binding still takes only the
values, and a surface offers the labels.
Sourcepub fn choosing_people<S: Into<String>>(
self,
people: impl IntoIterator<Item = S>,
) -> Self
pub fn choosing_people<S: Into<String>>( self, people: impl IntoIterator<Item = S>, ) -> Self
Mark which choices are people (PEOPLE_ANNOTATION): each is shown
with the avatar of its label, keyed by its value. Choices not named
(a “Create new” beside the identities) read as text alone.
Sourcepub fn picking(self, pick: Pick) -> Self
pub fn picking(self, pick: Pick) -> Self
Have a person pick this parameter’s value from the workspace’s
picks (PICK_ANNOTATION); callers that know the value still give
it as the parameter’s type says. A resource is picked as a reference
(resource_reference_schema), whatever schema the parameter had.
Sourcepub fn pick(&self) -> Option<Pick>
pub fn pick(&self) -> Option<Pick>
What this parameter’s value picks from the workspace
(Self::picking).
Sourcepub fn choice_label(&self, choice: &str) -> Option<&str>
pub fn choice_label(&self, choice: &str) -> Option<&str>
How choice reads to a person (Self::with_labelled_choices).
Sourcepub fn shaped_by<V: Into<String>>(
self,
argument: &str,
shapes: impl IntoIterator<Item = (V, Value)>,
) -> Self
pub fn shaped_by<V: Into<String>>( self, argument: &str, shapes: impl IntoIterator<Item = (V, Value)>, ) -> Self
Let the value the argument argument is given decide this
parameter’s shape (SHAPED_BY_ANNOTATION): shapes names a schema
for each value of it that has one. A call is held to the shape its
own value of argument names, and to this parameter’s own schema
alone where it names none.
Sourcepub fn shapes_by(&self) -> Option<(&str, &Map<String, Value>)>
pub fn shapes_by(&self) -> Option<(&str, &Map<String, Value>)>
The argument whose value decides this parameter’s shape, and the
shape each of its values names, where the declaration says so
(SHAPED_BY_ANNOTATION).
Sourcepub fn resource_kind(&self) -> Option<&str>
pub fn resource_kind(&self) -> Option<&str>
The kind of resource this parameter takes, when it is a resource
parameter that names one (Self::of_resource_kind).
Sourcepub fn as_place(self) -> Self
pub fn as_place(self) -> Self
Make this a place inside the resource the action is on: an object
naming one of its items ({"item": id}), a caret in it
({"item": id, "at": n}) or a range of it
({"item": id, "start": n, "end": n}). Marked with the
PLACE_ANNOTATION, so a palette or an agent offers the resource’s
items rather than free text. An action given one acts there instead
of at the invoker’s caret.
Sourcepub fn as_place_in(self, field: &str) -> Self
pub fn as_place_in(self, field: &str) -> Self
Self::as_place, its items being those of the collection field
(a document’s paragraphs, blocks): the item resources published as
<resource>/<field>/<item>.
Sourcepub fn as_content(self) -> Self
pub fn as_content(self) -> Self
Make this text parameter the address of content another action
produced: a caller chains it from that action’s result, never from
words (marked with the CONTENT_ANNOTATION).
Sourcepub fn as_content_list(self) -> Self
pub fn as_content_list(self) -> Self
Make this list parameter a list of content addresses, each one
content another action produced (Self::as_content), in order.
Sourcepub fn is_content_list(&self) -> bool
pub fn is_content_list(&self) -> bool
Whether this parameter takes a list of content
(Self::as_content_list).
Sourcepub fn is_content(&self) -> bool
pub fn is_content(&self) -> bool
Whether this parameter takes content another action produced
(Self::as_content).
Sourcepub fn is_place(&self) -> bool
pub fn is_place(&self) -> bool
Whether this parameter is a place inside the resource
(Self::as_place).
Sourcepub fn place_field(&self) -> Option<&str>
pub fn place_field(&self) -> Option<&str>
The collection whose items this place parameter names, when it says
(Self::as_place_in).
pub fn nullable(self) -> Self
Sourcepub fn declared_shape(&self) -> Option<String>
pub fn declared_shape(&self) -> Option<String>
How a value of this parameter is written, where its declaration says
more of it than its type does (the keys of an object, the items of a
list, its choices, its bounds): JSON with a word in angle brackets
where a value goes and ? after a key that may be left out. What a
listing shows before a call, and what a refusal tells after one.
Sourcepub fn validate_declaration(&self) -> Vec<String>
pub fn validate_declaration(&self) -> Vec<String>
Validate this parameter’s descriptor independently of any supplied value, suitable for an untrusted publication boundary.
Trait Implementations§
Source§impl Clone for ActionParam
impl Clone for ActionParam
Source§impl Debug for ActionParam
impl Debug for ActionParam
Source§impl<'de> Deserialize<'de> for ActionParam
impl<'de> Deserialize<'de> for ActionParam
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for ActionParam
Source§impl PartialEq for ActionParam
impl PartialEq for ActionParam
Source§impl Serialize for ActionParam
impl Serialize for ActionParam
impl StructuralPartialEq for ActionParam
Auto Trait Implementations§
impl Forget for ActionParam
impl Freeze for ActionParam
impl Move for ActionParam
impl RefUnwindSafe for ActionParam
impl Send for ActionParam
impl Sync for ActionParam
impl Unpin for ActionParam
impl UnsafeUnpin for ActionParam
impl UnwindSafe for ActionParam
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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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