Skip to main content

TypedDecisionResponse

Struct TypedDecisionResponse 

Source
pub struct TypedDecisionResponse<S: AnswerSchema = DynamicSchema> { /* private fields */ }
Expand description

Validated response retaining request keys and an optional named answer shape.

Implementations§

Source§

impl<S: AnswerSchema> TypedDecisionResponse<S>

Source

pub fn raw(&self) -> &DecisionResponse

Native response, borrowed immutably for extension fields.

Source

pub fn model(&self) -> &str

Model actually used.

Source

pub fn usage(&self) -> &Usage

Native usage.

Source

pub fn answers(&self) -> Result<S::Answers<'_>, Error>

Borrow named fields inferred by crate::questions!, or a map for dynamic questions. The normal macro-generated schema has already been validated before the client returns.

Source

pub fn answer(&self, id: &str) -> Result<AnswerResult<'_>, Error>

Look up a checked answer by its request key. Match the enum for dynamic heterogeneous keys.

Source

pub fn choice(&self, id: &str) -> Result<ChoiceAnswer<'_>, Error>

Look up a choice answer by key; a different question kind is an error.

Source

pub fn noul(&self, id: &str) -> Result<NoulAnswer<'_>, Error>

Look up a yes/no answer by key.

Source

pub fn score(&self, id: &str) -> Result<ScoreAnswer<'_>, Error>

Look up a score answer by key.

Source

pub fn multi(&self, id: &str) -> Result<MultiAnswer<'_>, Error>

Look up a multi answer by key.

Source

pub fn tool(&self, id: &str) -> Result<ToolAnswer<'_>, Error>

Look up a tool routing answer by key.

Source

pub fn act(&self, id: &str) -> Result<ActAnswer<'_>, Error>

Look up an action answer by key.

Trait Implementations§

Source§

impl<S: Debug + AnswerSchema> Debug for TypedDecisionResponse<S>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<S> Freeze for TypedDecisionResponse<S>
where S: Freeze,

§

impl<S> RefUnwindSafe for TypedDecisionResponse<S>
where S: RefUnwindSafe,

§

impl<S> Send for TypedDecisionResponse<S>
where S: Send,

§

impl<S> Sync for TypedDecisionResponse<S>
where S: Sync,

§

impl<S> Unpin for TypedDecisionResponse<S>
where S: Unpin,

§

impl<S> UnsafeUnpin for TypedDecisionResponse<S>
where S: UnsafeUnpin,

§

impl<S> UnwindSafe for TypedDecisionResponse<S>
where S: UnwindSafe,

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, 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