Skip to main content

OperationSpec

Struct OperationSpec 

Source
#[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
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§key: OperationKey

Its key, unique across the registry.

§workflow: WorkflowKey

The workflow offering it; the registry fills it in.

§summary: String

One 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: TargetPolicy

Which records it may aim at.

§mutability: ActMutability

Whether it changes a record.

§availability: ActAvailability

Whether a model may propose it, or only a card.

§arguments_schema: Schema

The 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

Source

pub fn new(key: impl Into<OperationKey>) -> Self

An operation named key that takes no arguments and changes an existing record.

Source

pub fn summary(self, summary: impl Into<String>) -> Self

Says in one line what it does.

Source

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.

Source

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.

Source

pub fn guidance(self, guidance: impl Into<String>) -> Self

Adds guidance for filling its arguments.

Source

pub const fn target(self, policy: TargetPolicy) -> Self

Sets which records it may aim at.

Source

pub const fn read_only(self) -> Self

Marks it as changing nothing.

Source

pub const fn mutating(self) -> Self

Marks it as changing a record, which is the default.

Source

pub const fn card_only(self) -> Self

Lets only a card run it.

Source

pub fn arguments<A: JsonSchema + DeserializeOwned + 'static>(self) -> Self

Takes its arguments from A, deriving one ArgumentSpec per top-level field.

Source

pub fn argument( self, name: &str, adjust: impl FnOnce(ArgumentSpec) -> ArgumentSpec, ) -> Self

Adjusts the argument named name.

Source

pub fn example(self, message: impl Into<String>, arguments: Value) -> Self

Adds an example message and the arguments it gives.

Source

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.

Source

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

Source

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.

Source

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.

Source

pub fn argument_named(&self, name: &str) -> Option<&ArgumentSpec>

The argument named name.

Source

pub fn validate(&self) -> Result<(), OperationSpecError>

Checks the declaration: every adjusted argument exists, and every example gives arguments of the right type and names only real ones.

§Errors

The first problem found, naming the operation.

Trait Implementations§

Source§

impl Clone for OperationSpec

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 OperationSpec

Source§

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

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

impl<'de> Deserialize<'de> for OperationSpec

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 PartialEq for OperationSpec

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 OperationSpec

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

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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.