Skip to main content

Session

Trait Session 

Source
pub trait Session: Send + Sync {
    // Required methods
    fn id(&self) -> &str;
    fn app_name(&self) -> &str;
    fn user_id(&self) -> &str;
    fn state(&self) -> &dyn State;
    fn events(&self) -> &dyn Events;
    fn last_update_time(&self) -> DateTime<Utc>;

    // Provided methods
    fn try_app_name(&self) -> Result<AppName> { ... }
    fn try_user_id(&self) -> Result<UserId> { ... }
    fn try_session_id(&self) -> Result<SessionId> { ... }
    fn try_identity(&self) -> Result<AdkIdentity> { ... }
}
Expand description

Trait representing a conversation session with state and event history.

Required Methods§

Source

fn id(&self) -> &str

Returns the session identifier.

Source

fn app_name(&self) -> &str

Returns the application name that owns this session.

Source

fn user_id(&self) -> &str

Returns the user identifier for the session owner.

Source

fn state(&self) -> &dyn State

Returns a reference to the session’s state store.

Source

fn events(&self) -> &dyn Events

Returns a reference to the session’s event history.

Source

fn last_update_time(&self) -> DateTime<Utc>

Returns the timestamp of the last update to this session.

Provided Methods§

Source

fn try_app_name(&self) -> Result<AppName>

Returns the application name as a typed AppName.

Parses the value returned by app_name(). Returns an error if the raw string fails validation (empty, null bytes, or exceeds the maximum length).

§Errors

Returns AdkError::config when the underlying string is not a valid identifier.

Source

fn try_user_id(&self) -> Result<UserId>

Returns the user identifier as a typed UserId.

Parses the value returned by user_id(). Returns an error if the raw string fails validation.

§Errors

Returns AdkError::config when the underlying string is not a valid identifier.

Source

fn try_session_id(&self) -> Result<SessionId>

Returns the session identifier as a typed SessionId.

Parses the value returned by id(). Returns an error if the raw string fails validation.

§Errors

Returns AdkError::config when the underlying string is not a valid identifier.

Source

fn try_identity(&self) -> Result<AdkIdentity>

Returns the stable session-scoped AdkIdentity triple.

Combines try_app_name(), try_user_id(), and try_session_id() into a single composite identity value.

§Errors

Returns an error if any of the three constituent identifiers fail validation.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§