Skip to main content

Session

Trait Session 

Source
pub trait Session:
    Send
    + Sync
    + Debug {
    // Required methods
    fn session_id(&self) -> &str;
    fn get_items<'life0, 'async_trait>(
        &'life0 self,
        limit: Option<usize>,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<RunItem>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn add_items<'life0, 'async_trait>(
        &'life0 self,
        items: Vec<RunItem>,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn pop_item<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<Option<RunItem>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn clear_session<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided method
    fn get_messages<'life0, 'async_trait>(
        &'life0 self,
        limit: Option<usize>,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<Message>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
}
Expand description

Defines the interface for session storage implementations.

Required Methods§

Source

fn session_id(&self) -> &str

Returns the unique identifier for the session.

Source

fn get_items<'life0, 'async_trait>( &'life0 self, limit: Option<usize>, ) -> Pin<Box<dyn Future<Output = Result<Vec<RunItem>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Retrieves a list of RunItems from the session.

Source

fn add_items<'life0, 'async_trait>( &'life0 self, items: Vec<RunItem>, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Adds a vector of RunItems to the session.

Source

fn pop_item<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Option<RunItem>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Removes and returns the most recent RunItem from the session.

Source

fn clear_session<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Clears all items from the session, effectively resetting the conversation.

Provided Methods§

Source

fn get_messages<'life0, 'async_trait>( &'life0 self, limit: Option<usize>, ) -> Pin<Box<dyn Future<Output = Result<Vec<Message>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Retrieves the conversation history as a vector of Messages.

Implementors§