Skip to main content

UnderstandingBuilder

Struct UnderstandingBuilder 

Source
pub struct UnderstandingBuilder { /* private fields */ }
Expand description

Builds an Understanding of one message from quotes of it.

use turnframe_test::providers::UnderstandingBuilder;

let understanding = UnderstandingBuilder::of("set the name to Lisbon")
    .apply("trip.set_name", "tok_1", serde_json::json!({"value": "Lisbon"}), "set the name to Lisbon")
    .build()
    .unwrap();
assert_eq!(understanding.acts[0].arguments["value"].excerpt.unwrap().words.first, 4);

Implementations§

Source§

impl UnderstandingBuilder

Source

pub fn of(text: impl AsRef<str>) -> Self

Starts an understanding of text.

Source

pub fn text(&self) -> &str

The message, as given.

Source

pub fn apply( self, operation: impl Into<OperationKey>, target: impl Into<TargetToken>, arguments: Value, quote: &str, ) -> Self

An act applying operation to the record target names, asked for in quote.

Source

pub fn apply_to( self, operation: impl Into<OperationKey>, target: ActTarget, arguments: Value, quote: &str, ) -> Self

An act applying operation to any target.

Source

pub fn apply_to_unlisted( self, operation: impl Into<OperationKey>, workflow: impl Into<WorkflowKey>, named: &str, arguments: Value, quote: &str, ) -> Self

An act applying operation to a record of workflow the user named in named that is not in view, for the directory to look up.

Source

pub fn open( self, operation: impl Into<OperationKey>, workflow: impl Into<WorkflowKey>, arguments: Value, quote: &str, ) -> Self

An act applying operation to a record of workflow it creates.

Source

pub fn start(self, workflow: impl Into<WorkflowKey>, quote: &str) -> Self

An act starting a new case of workflow.

Source

pub fn with_record(self, name: &str, record: RecordValue) -> Self

Gives the last act an argument naming a record. A record an earlier act of the turn creates makes that act a prerequisite.

Source

pub fn last_act(&self) -> Option<ActId>

The id of the act added last.

Source

pub fn with_status(self, status: ActStatus) -> Self

Replaces the last act’s status.

Source

pub fn needing(self, arguments: &[&str]) -> Self

Marks the last act as asking for arguments.

Source

pub fn superseded_by_next(self) -> Self

Marks the last act as superseded by a later unit, removing it from the acts.

Source

pub fn ask(self, quote: &str) -> Self

A question answered against the current committed state.

Source

pub fn ask_about( self, basis: AnswerBasis, record: Option<TargetToken>, subjects: &[&str], quote: &str, ) -> Self

A question with its basis, record and subjects; one on general domain knowledge is about the domain, the rest about a record, until Self::about says otherwise.

Source

pub fn following_up(self) -> Self

Marks the last question as following up the assistant’s last message.

Source

pub fn about(self, topic: QuestionTopic) -> Self

Sets what kind of thing the last question asks.

Source

pub fn constrain(self, kind: ConstraintKind, quote: &str) -> Self

A turn-wide constraint stated in quote.

Source

pub fn answer_card(self, option: impl Into<OptionId>, quote: &str) -> Self

A typed answer to the card on screen.

Source

pub fn dispute(self, receipt: Option<&str>, quote: &str) -> Self

A dispute of the receipt shown under receipt, when it names one.

Source

pub fn not_understood(self, reason: NotUnderstoodReason, quote: &str) -> Self

Words that produced nothing to act on.

Source

pub fn chitchat(self, quote: &str) -> Self

Greetings, thanks, words that ask for nothing.

Source

pub fn build(self) -> Result<Understanding, QuoteNotFound>

Finishes the understanding.

§Errors

QuoteNotFound for the first quote that is not in the text.

Trait Implementations§

Source§

impl Clone for UnderstandingBuilder

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 UnderstandingBuilder

Source§

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

Formats the value using the given formatter. 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> 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> 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> 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.
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