Skip to main content

ActionParam

Struct ActionParam 

Source
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: bool

Whether 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: bool

Whether 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: bool

Explicitly permits JSON null. Optional means omitted; nullable means present with no value, and callers need to distinguish the two.

Implementations§

Source§

impl ActionParam

Source

pub const fn required( name: &'static str, ty: ParamType, description: &'static str, ) -> Self

A required parameter with static strings — usable in a const.

Source

pub const fn optional( name: &'static str, ty: ParamType, description: &'static str, ) -> Self

An optional parameter with static strings — usable in a const.

Source

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.

Source

pub fn optional_owned( name: impl Into<Str>, ty: ParamType, description: impl Into<Str>, ) -> Self

An optional parameter whose strings are built at runtime.

Source

pub fn taking_entry(self) -> Self

Have one line of typed text fill this parameter, and the parameters the words say (ActionParam::entry).

Source

pub fn with_choices<S: Into<Str>>( self, choices: impl IntoIterator<Item = S>, ) -> Self

Restrict this parameter to choices. Binding refuses anything else.

Source

pub fn with_schema(self, schema: Value) -> Self

Source

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.

Source

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.

Source

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.

Source

pub fn with_shared_schema(self, schema: Arc<Value>) -> Self

Retain an immutable schema already shared by the current type generation. Wire serialization and strict argument validation are unchanged.

Source

pub fn taking_resource_kinds<I, S>(self, kinds: I) -> Self
where I: IntoIterator<Item = S>, S: Into<String>,

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.

Source

pub fn resource_kinds(&self) -> Vec<&str>

The kinds of resource this parameter takes, when it names several (Self::taking_resource_kinds).

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn pick(&self) -> Option<Pick>

What this parameter’s value picks from the workspace (Self::picking).

Source

pub fn choice_label(&self, choice: &str) -> Option<&str>

How choice reads to a person (Self::with_labelled_choices).

Source

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.

Source

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

Source

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

Source

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.

Source

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

Source

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

Source

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.

Source

pub fn is_content_list(&self) -> bool

Whether this parameter takes a list of content (Self::as_content_list).

Source

pub fn is_content(&self) -> bool

Whether this parameter takes content another action produced (Self::as_content).

Source

pub fn is_place(&self) -> bool

Whether this parameter is a place inside the resource (Self::as_place).

Source

pub fn place_field(&self) -> Option<&str>

The collection whose items this place parameter names, when it says (Self::as_place_in).

Source

pub fn nullable(self) -> Self

Source

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.

Source

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

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 ActionParam

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for ActionParam

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for ActionParam

Source§

impl PartialEq for ActionParam

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for ActionParam

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for ActionParam

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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