Skip to main content

State

Struct State 

Source
pub struct State<S, R> {
    pub conversations: HashMap<String, Conversation<S>>,
    pub by_thread: HashMap<String, String>,
    pub pending: HashMap<u64, Pending<R>>,
    pub tools: HashMap<ToolToken, PendingTool>,
    pub rpc_ids: HashSet<String>,
    pub next_id: u64,
    pub next_turn: u64,
}

Fields§

§conversations: HashMap<String, Conversation<S>>§by_thread: HashMap<String, String>§pending: HashMap<u64, Pending<R>>§tools: HashMap<ToolToken, PendingTool>§rpc_ids: HashSet<String>§next_id: u64§next_turn: u64

Implementations§

Source§

impl<S, R> State<S, R>

Source

pub fn allocate_request_id(&mut self) -> Result<u64, Error>

Source

pub fn allocate_turn_id(&mut self) -> Result<u64, Error>

Source

pub fn begin_turn( &mut self, key: impl Into<String>, sink: S, ) -> Result<u64, Error>

Source

pub fn take_active(&mut self, key: &str, serial: u64) -> Option<Active<S>>

Source

pub fn set_native_turn( &mut self, key: &str, serial: u64, turn: impl Into<String>, ) -> Option<Vec<Value>>

Source

pub fn interrupt_target( &mut self, key: &str, serial: u64, ) -> Option<(String, String)>

Source

pub fn take_sinks(&mut self) -> Vec<S>

Source

pub fn thread(&self, key: &str) -> Option<&str>

Source

pub fn owner(&self, thread: &str) -> Option<&str>

Source

pub fn set_thread( &mut self, key: &str, thread: impl Into<String>, ) -> Result<(), Error>

Source

pub fn begin_close(&mut self, key: &str) -> Result<Option<String>, Error>

Source

pub fn cancel_close(&mut self, key: &str)

Source

pub fn finish_close(&mut self, key: &str, thread: &str) -> Result<(), Error>

Source

pub fn insert_pending( &mut self, id: u64, pending: Pending<R>, ) -> Result<(), Error>

Source

pub fn take_pending(&mut self, id: u64) -> Result<Pending<R>, Error>

Source

pub fn track_tool( &mut self, key: &str, serial: u64, call: impl Into<String>, id: &Value, ) -> Result<ToolToken, Error>

Source

pub fn take_tool(&mut self, token: &ToolToken) -> Option<PendingTool>

Source

pub fn take_turn_tools( &mut self, key: &str, serial: u64, ) -> Vec<(ToolToken, PendingTool)>

Source

pub fn resolve_tool(&mut self, id: &Value) -> Result<Option<ToolToken>, Error>

Trait Implementations§

Source§

impl<S, R> Default for State<S, R>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<S, R> Freeze for State<S, R>

§

impl<S, R> RefUnwindSafe for State<S, R>

§

impl<S, R> Send for State<S, R>

§

impl<S, R> Sync for State<S, R>

§

impl<S, R> Unpin for State<S, R>

§

impl<S, R> UnsafeUnpin for State<S, R>

§

impl<S, R> UnwindSafe for State<S, R>

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