Struct ActionParam
pub struct ActionParam {
pub name: Cow<'static, str>,
pub ty: ParamType,
pub required: bool,
pub entry: 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.
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: 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 taking_entry(self) -> ActionParam
pub fn taking_entry(self) -> ActionParam
Have one line of typed text fill this parameter, and the parameters
the words say (ActionParam::entry).
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 with_labelled_choices<V, L>(
self,
choices: impl IntoIterator<Item = (V, L)>,
) -> ActionParam
pub fn with_labelled_choices<V, L>( self, choices: impl IntoIterator<Item = (V, L)>, ) -> ActionParam
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.
pub fn choosing_people<S>(
self,
people: impl IntoIterator<Item = S>,
) -> ActionParam
pub fn choosing_people<S>( self, people: impl IntoIterator<Item = S>, ) -> ActionParam
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.
pub fn picking(self, pick: Pick) -> ActionParam
pub fn picking(self, pick: Pick) -> ActionParam
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.
pub fn pick(&self) -> Option<Pick>
pub fn pick(&self) -> Option<Pick>
What this parameter’s value picks from the workspace
(Self::picking).
pub 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).
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 as_content_list(self) -> ActionParam
pub fn as_content_list(self) -> ActionParam
Make this list parameter a list of content addresses, each one
content another action produced (Self::as_content), in order.
pub 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).
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 Model for ActionParam
impl Model for ActionParam
§const TABLE: &'static ModelTable
const TABLE: &'static ModelTable
crate::table]): by default its own functions, erased.§type Paths<R> = Path<R, ActionParam>
type Paths<R> = Path<R, ActionParam>
R:
a struct of field paths for a record, the Path itself for a value
edited whole or through its own operations.§fn paths_at<R>(path: Path<R, ActionParam>) -> Path<R, ActionParam>
fn paths_at<R>(path: Path<R, ActionParam>) -> Path<R, ActionParam>
path.§fn op_coalesces(
path: &[Segment],
previous: &Value,
next: &Value,
) -> Option<bool>
fn op_coalesces( path: &[Segment], previous: &Value, next: &Value, ) -> Option<bool>
path below
this type are one gesture (Operations); None
when nothing there has one.§fn op_continuable(path: &[Segment], op: &Value) -> Option<bool>
fn op_continuable(path: &[Segment], op: &Value) -> Option<bool>
op at path.§fn op_describe(path: &[Segment], op: &Value) -> Option<OpDescription>
fn op_describe(path: &[Segment], op: &Value) -> Option<OpDescription>
§fn op_lands(&self, path: &[Segment], op: &Value) -> Option<Place>
fn op_lands(&self, path: &[Segment], op: &Value) -> Option<Place>
op at path below this value is after
it applied.§fn op_schemas(prefix: &str, out: &mut Vec<(String, Value)>)
fn op_schemas(prefix: &str, out: &mut Vec<(String, Value)>)
prefix (* for every item).§fn from_json(value: &Value) -> Result<ActionParam, ModelError>
fn from_json(value: &Value) -> Result<ActionParam, ModelError>
Self::to_json form. Read more§fn edit(
doc: &mut AutoCommit,
slot: Slot<'_>,
path: &[Segment],
op: &EditOp,
cx: &mut ActionCx,
) -> Result<(), ModelError>
fn edit( doc: &mut AutoCommit, slot: Slot<'_>, path: &[Segment], op: &EditOp, cx: &mut ActionCx, ) -> Result<(), ModelError>
op at path, below the value in slot,
touching only what it changes, then run the invariants of the values
it touched. The default edits a value only as a whole.§fn check(&self) -> Result<(), Refusal>
fn check(&self) -> Result<(), Refusal>
#[model(check)] invariant of this value and the values
inside it.§fn get_at(&self, path: &[Segment]) -> Option<&(dyn Any + 'static)>
fn get_at(&self, path: &[Segment]) -> Option<&(dyn Any + 'static)>
path below this one, if it is there. A value with
nothing inside it is found only at the empty path.§fn diff<R>(&self, after: &ActionParam, path: &[Segment], out: &mut Vec<Edit<R>>)
fn diff<R>(&self, after: &ActionParam, path: &[Segment], out: &mut Vec<Edit<R>>)
self into after, at path below the
record: what a surface that edited a local copy submits. The default
sets the value whole when it changed; containers and records edit
only what differs, item by item and field by field. A value that
would store as it is (Self::stores_as) is compared in memory,
without turning either side into JSON.§fn load(
doc: &AutoCommit,
value: &Value<'_>,
id: &ExId,
) -> Result<ActionParam, ModelError>
fn load( doc: &AutoCommit, value: &Value<'_>, id: &ExId, ) -> Result<ActionParam, ModelError>
§fn store(&self, doc: &mut AutoCommit, slot: Slot<'_>) -> Result<(), ModelError>
fn store(&self, doc: &mut AutoCommit, slot: Slot<'_>) -> Result<(), ModelError>
self into slot, changing only what differs from what the slot
already holds.§fn stores_as(&self, before: &ActionParam) -> bool
fn stores_as(&self, before: &ActionParam) -> bool
self over a slot that holds before, as a
store left it, would change nothing: an in-memory
comparison, so an action that changed one item of a long collection
does not visit the others. Must only answer true when store would
write no operation; the default answers false (unknown).§fn store_changed(
&self,
before: &ActionParam,
doc: &mut AutoCommit,
slot: Slot<'_>,
dirty: &Delta,
) -> Result<(), ModelError>
fn store_changed( &self, before: &ActionParam, doc: &mut AutoCommit, slot: Slot<'_>, dirty: &Delta, ) -> Result<(), ModelError>
§fn refresh(
&mut self,
doc: &AutoCommit,
value: &Value<'_>,
id: &ExId,
delta: &Delta,
) -> Result<(), ModelError>
fn refresh( &mut self, doc: &AutoCommit, value: &Value<'_>, id: &ExId, delta: &Delta, ) -> Result<(), ModelError>
delta,
re-reading only what they touched. value and id are what the
parent’s slot holds now — the same object as when self was read, or
the parent would have read it anew. The default reads the value again,
which is right for scalars and short values. Read more§fn collect_text(&self, out: &mut Vec<String>)
fn collect_text(&self, out: &mut Vec<String>)
§fn missing() -> Result<ActionParam, ModelError>
fn missing() -> Result<ActionParam, ModelError>
§const SHAPE: Shape = crate::Shape::Value
const SHAPE: Shape = crate::Shape::Value
Shape.
Types written whole keep the default.§const CHECKS: bool = false
const CHECKS: bool = false
#[model(check)]
invariant; Self::check has nothing to do otherwise.§const OPS: bool = false
const OPS: bool = false
Operations, rich text’s): a record routes
those edits’ gestures, landing places and schemas only into such
fields, and never instantiates the routing for the others.§const NULLABLE: bool = false
const NULLABLE: bool = false
null is a value of the type: an absent Option. A field
edit setting any other type to null is refused.§fn nested_collections(&self) -> Vec<ItemCollection>
fn nested_collections(&self) -> Vec<ItemCollection>
#[derive(Model)] lists a
record’s, the default has none.§fn value_schema() -> Value
fn value_schema() -> Value
Self::to_json), as
the published field edit describes what a path takes; the default
accepts any value.§fn field_type(types: &mut TypeSet) -> FieldType
fn field_type(types: &mut TypeSet) -> FieldType
FieldType), declaring the records
and enums it names in types. The default describes no type: any
value.§fn read_whole(&mut self, doc: &AutoCommit) -> Result<(), ModelError>
fn read_whole(&mut self, doc: &AutoCommit) -> Result<(), ModelError>
#[model(whole)]: a value read lazily (rich text reads its
paragraphs as views ask for them) reads all of it, so every reader of
the record — a verb, search, read_content — sees all of it. The
default has nothing more to read. Read more§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 Settable 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> 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>, which can then be
downcast into Box<dyn 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>, which 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> DowncastSend for T
impl<T> DowncastSend for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§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