Struct ActionParam
pub struct ActionParam {
pub name: Cow<'static, str>,
pub ty: ParamType,
pub required: bool,
pub description: Cow<'static, str>,
pub choices: Vec<Cow<'static, str>>,
pub schema: Option<Arc<Value>>,
pub nullable: bool,
}Expand description
One typed parameter an action declares.
Fields§
§name: Cow<'static, 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.
description: Cow<'static, str>§choices: Vec<Cow<'static, 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§
§impl ActionParam
impl ActionParam
pub const fn required(
name: &'static str,
ty: ParamType,
description: &'static str,
) -> ActionParam
pub const fn required( name: &'static str, ty: ParamType, description: &'static str, ) -> ActionParam
A required parameter with static strings — usable in a const.
pub const fn optional(
name: &'static str,
ty: ParamType,
description: &'static str,
) -> ActionParam
pub const fn optional( name: &'static str, ty: ParamType, description: &'static str, ) -> ActionParam
An optional parameter with static strings — usable in a const.
pub fn required_owned(
name: impl Into<Cow<'static, str>>,
ty: ParamType,
description: impl Into<Cow<'static, str>>,
) -> ActionParam
pub fn required_owned( name: impl Into<Cow<'static, str>>, ty: ParamType, description: impl Into<Cow<'static, str>>, ) -> ActionParam
A required parameter whose strings are built at runtime — what an app declaring parameters out of live document state needs.
pub fn optional_owned(
name: impl Into<Cow<'static, str>>,
ty: ParamType,
description: impl Into<Cow<'static, str>>,
) -> ActionParam
pub fn optional_owned( name: impl Into<Cow<'static, str>>, ty: ParamType, description: impl Into<Cow<'static, str>>, ) -> ActionParam
An optional parameter whose strings are built at runtime.
pub fn with_choices<S>(
self,
choices: impl IntoIterator<Item = S>,
) -> ActionParam
pub fn with_choices<S>( self, choices: impl IntoIterator<Item = S>, ) -> ActionParam
Restrict this parameter to choices. Binding refuses anything else.
pub fn with_schema(self, schema: Value) -> ActionParam
Retain an immutable schema already shared by the current type generation. Wire serialization and strict argument validation are unchanged.
pub fn of_resource_kind(self, kind: impl Into<String>) -> ActionParam
pub fn of_resource_kind(self, kind: impl Into<String>) -> ActionParam
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.
pub 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).
pub fn as_place(self) -> ActionParam
pub fn as_place(self) -> ActionParam
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.
pub fn as_place_in(self, field: &str) -> ActionParam
pub fn as_place_in(self, field: &str) -> ActionParam
Self::as_place, its items being those of the collection field
(a document’s paragraphs, blocks): the item resources published as
<resource>/<field>/<item>.
pub fn as_content(self) -> ActionParam
pub fn as_content(self) -> ActionParam
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).
pub fn is_content(&self) -> bool
pub fn is_content(&self) -> bool
Whether this parameter takes content another action produced
(Self::as_content).
pub fn is_place(&self) -> bool
pub fn is_place(&self) -> bool
Whether this parameter is a place inside the resource
(Self::as_place).
pub 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) -> ActionParam
pub 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§
§impl Clone for ActionParam
impl Clone for ActionParam
§fn clone(&self) -> ActionParam
fn clone(&self) -> ActionParam
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl Debug for ActionParam
impl Debug for ActionParam
§impl<'de> Deserialize<'de> for ActionParam
impl<'de> Deserialize<'de> for ActionParam
§fn deserialize<__D>(
__deserializer: __D,
) -> Result<ActionParam, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<ActionParam, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
§impl PartialEq for ActionParam
impl PartialEq for ActionParam
§impl Serialize for ActionParam
impl Serialize for ActionParam
§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl Eq for ActionParam
impl StructuralPartialEq for ActionParam
Auto Trait Implementations§
impl Freeze 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§
§impl<T> AnyEq for T
impl<T> AnyEq for T
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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