Skip to main content

SystemOneRequest

Struct SystemOneRequest 

Source
pub struct SystemOneRequest<'a> { /* private fields */ }
Expand description

A POST /v1/systemone call under construction. Created by Client::system_one.

Set the state once with state (any Serialize, typically your own struct) or build it field by field with field, add questions, then send. Errors in the inputs (unserializable value, fields added to a non-object state, no state, no questions) surface from send, so the chain stays clean.

Implementations§

Source§

impl<'a> SystemOneRequest<'a>

Source

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

Model for this call only. Defaults to the client’s model.

Source

pub fn state(self, state: impl Serialize) -> Self

The whole state: a string, or any Serialize value (your own struct, a Vec, a serde_json::Value). Replaces anything set before.

Source

pub fn field(self, name: impl Into<String>, value: impl Serialize) -> Self

One named field of an object state. Call it once per field; a later state replaces them all. Fails at send if the state was already set to something that is not an object.

Source

pub fn question(self, id: impl Into<String>, question: Question) -> Self

Any question under id. Answers come back under the same id.

Source

pub fn noul(self, id: impl Into<String>, instructions: impl Into<Value>) -> Self

Yes/no question.

Source

pub fn noul_with_criteria( self, id: impl Into<String>, instructions: impl Into<Value>, yes: impl Into<String>, no: impl Into<String>, ) -> Self

Yes/no question with descriptions of what yes and no mean.

Source

pub fn choice( self, id: impl Into<String>, instructions: impl Into<Value>, options: impl FnOnce(ChoiceBuilder) -> ChoiceBuilder, ) -> Self

Pick one option; build the option set in the closure. Repeating an option name is an error at send, as is an empty set or more than MAX_CHOICE_OPTIONS options.

Source

pub fn score<L: Into<String>>( self, id: impl Into<String>, instructions: impl Into<Value>, levels: impl IntoIterator<Item = L>, ) -> Self

Rate along levels, lowest first. Fewer than two levels is an error at send.

Source

pub async fn send(self) -> Result<SystemOneResponse>

Send the request.

§Errors

Error::InvalidRequest for a request that is not sendable as built: no state, no questions, a Choice without options or with more than MAX_CHOICE_OPTIONS, a repeated option name, a Score with fewer than two levels, a duplicate question id, or a field added to a non-object state. Error::RequestSerialization if a state/field value failed to serialise. Otherwise as Client::evaluate.

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for SystemOneRequest<'a>

§

impl<'a> !UnwindSafe for SystemOneRequest<'a>

§

impl<'a> Freeze for SystemOneRequest<'a>

§

impl<'a> Send for SystemOneRequest<'a>

§

impl<'a> Sync for SystemOneRequest<'a>

§

impl<'a> Unpin for SystemOneRequest<'a>

§

impl<'a> UnsafeUnpin for SystemOneRequest<'a>

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<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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. 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<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