#[non_exhaustive]pub struct OperationSpec {
pub key: OperationKey,
pub workflow: WorkflowKey,
pub summary: String,
pub summaries: BTreeMap<Locale, String>,
pub guidance: Option<String>,
pub target_policy: TargetPolicy,
pub mutability: ActMutability,
pub availability: ActAvailability,
pub arguments_schema: Schema,
pub arguments: Vec<ArgumentSpec>,
pub examples: Vec<OperationExample>,
pub context_reads: Vec<ReadToolKey>,
/* private fields */
}Expand description
One operation a workflow offers in a view.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.key: OperationKeyIts key, unique across the registry.
workflow: WorkflowKeyThe workflow offering it; the registry fills it in.
summary: StringOne line saying what it does, for choosing among operations.
summaries: BTreeMap<Locale, String>The summary in other languages, by locale; the one above serves every other.
guidance: Option<String>Longer guidance for filling its arguments.
target_policy: TargetPolicyWhich records it may aim at.
mutability: ActMutabilityWhether it changes a record.
availability: ActAvailabilityWhether a model may propose it, or only a card.
arguments_schema: SchemaThe JSON Schema of its arguments type.
arguments: Vec<ArgumentSpec>Its arguments, in the schema’s order.
examples: Vec<OperationExample>Examples of messages and what they give.
context_reads: Vec<ReadToolKey>Reads whose results the argument filler is to be shown; declared, not yet run.
Implementations§
Source§impl OperationSpec
impl OperationSpec
Sourcepub fn new(key: impl Into<OperationKey>) -> Self
pub fn new(key: impl Into<OperationKey>) -> Self
An operation named key that takes no arguments and changes an existing record.
Sourcepub fn summary_in(
self,
locale: impl Into<Locale>,
summary: impl Into<String>,
) -> Self
pub fn summary_in( self, locale: impl Into<Locale>, summary: impl Into<String>, ) -> Self
Says what it does in locale’s language, for a turn in that language.
Sourcepub fn summary_for(&self, locale: &Locale) -> &str
pub fn summary_for(&self, locale: &Locale) -> &str
Its summary for a turn in locale: that locale’s, then its language’s, then the
summary every other language reads.
Sourcepub fn guidance(self, guidance: impl Into<String>) -> Self
pub fn guidance(self, guidance: impl Into<String>) -> Self
Adds guidance for filling its arguments.
Sourcepub const fn target(self, policy: TargetPolicy) -> Self
pub const fn target(self, policy: TargetPolicy) -> Self
Sets which records it may aim at.
Sourcepub fn arguments<A: JsonSchema + DeserializeOwned + 'static>(self) -> Self
pub fn arguments<A: JsonSchema + DeserializeOwned + 'static>(self) -> Self
Takes its arguments from A, deriving one ArgumentSpec per top-level field.
Sourcepub fn argument(
self,
name: &str,
adjust: impl FnOnce(ArgumentSpec) -> ArgumentSpec,
) -> Self
pub fn argument( self, name: &str, adjust: impl FnOnce(ArgumentSpec) -> ArgumentSpec, ) -> Self
Adjusts the argument named name.
Sourcepub fn example(self, message: impl Into<String>, arguments: Value) -> Self
pub fn example(self, message: impl Into<String>, arguments: Value) -> Self
Adds an example message and the arguments it gives.
Sourcepub fn example_not_given<'a>(
self,
message: impl Into<String>,
names: impl IntoIterator<Item = &'a str>,
) -> Self
pub fn example_not_given<'a>( self, message: impl Into<String>, names: impl IntoIterator<Item = &'a str>, ) -> Self
Adds an example message that names or implies names without giving them.
Sourcepub fn context_read(self, read: impl Into<ReadToolKey>) -> Self
pub fn context_read(self, read: impl Into<ReadToolKey>) -> Self
Names a read whose result the argument filler is to be shown. Declared only:
no stage runs reads in 0.1 (docs/roadmap.md).
Sourcepub fn arguments_value(
&self,
values: impl IntoIterator<Item = (String, Value)>,
) -> Value
pub fn arguments_value( &self, values: impl IntoIterator<Item = (String, Value)>, ) -> Value
The arguments document an act passes: null for an operation declared with no
arguments type, an object otherwise.
Sourcepub fn check_arguments(&self, arguments: &Value) -> Result<(), String>
pub fn check_arguments(&self, arguments: &Value) -> Result<(), String>
Checks an act’s arguments against the arguments type.
§Errors
Why they do not fit, as a path and not as the value.
Sourcepub fn argument_named(&self, name: &str) -> Option<&ArgumentSpec>
pub fn argument_named(&self, name: &str) -> Option<&ArgumentSpec>
The argument named name.