pub struct ConversationHandler { /* private fields */ }Expand description
Handles all conversation store operations: creation, rehydration, and persistence.
Implementations§
Source§impl ConversationHandler
impl ConversationHandler
pub fn new(store: ConversationStore) -> Self
Sourcepub async fn get_or_create(
&self,
ctx: &RequestContext,
) -> ExecutorResult<ConversationData>
pub async fn get_or_create( &self, ctx: &RequestContext, ) -> ExecutorResult<ConversationData>
Gets an existing conversation or creates one.
Reads conversation_id from ctx.original_request.
§Errors
Returns ExecutorError if conversation_id is absent, the store is
disabled, or the database query fails.
Sourcepub async fn get(
&self,
ctx: &RequestContext,
) -> ExecutorResult<ConversationData>
pub async fn get( &self, ctx: &RequestContext, ) -> ExecutorResult<ConversationData>
Gets an existing conversation.
Reads conversation_id from ctx.original_request.
§Errors
Returns ExecutorError if conversation_id is absent, the store is
disabled, the conversation does not exist, or the database query fails.
Sourcepub async fn create(&self) -> ExecutorResult<ConversationData>
pub async fn create(&self) -> ExecutorResult<ConversationData>
Creates a brand-new conversation with a freshly generated ID.
§Errors
Returns ExecutorError if the store is disabled or the database query fails.
Sourcepub async fn rehydrate(
&self,
ctx: &RequestContext,
) -> ExecutorResult<Vec<InOutItem>>
pub async fn rehydrate( &self, ctx: &RequestContext, ) -> ExecutorResult<Vec<InOutItem>>
Loads all history items for the conversation referenced by the request.
Reads conversation_id from ctx.original_request. Returns an empty vec
if the conversation exists but has no items yet.
§Errors
Returns ExecutorError if conversation_id is absent, the store is
disabled, or the database query fails.
Sourcepub async fn rehydrate_snapshot(
&self,
ctx: &RequestContext,
) -> ExecutorResult<ConversationSnapshot>
pub async fn rehydrate_snapshot( &self, ctx: &RequestContext, ) -> ExecutorResult<ConversationSnapshot>
Loads the conversation’s history items and storage version.
Reads conversation_id from ctx.original_request.
§Errors
Returns ExecutorError if conversation_id is absent, the store is
disabled, or the database query fails.
Sourcepub async fn execute_turn(
&self,
ctx: RequestContext,
output_items: Vec<OutputItem>,
) -> ExecutorResult<()>
pub async fn execute_turn( &self, ctx: RequestContext, output_items: Vec<OutputItem>, ) -> ExecutorResult<()>
Persists one conversation turn — only the new items from this turn.
Takes ctx and output_items by value so fields can be moved directly
into ResponseMetadata without cloning. The store tracks sequence
numbers and appends, so prior history must not be re-inserted.
§Errors
Returns ExecutorError if conversation_id is absent on the context,
the store is disabled, or the database operation fails.
Trait Implementations§
Source§impl Clone for ConversationHandler
impl Clone for ConversationHandler
Source§fn clone(&self) -> ConversationHandler
fn clone(&self) -> ConversationHandler
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for ConversationHandler
impl !UnwindSafe for ConversationHandler
impl Freeze for ConversationHandler
impl Send for ConversationHandler
impl Sync for ConversationHandler
impl Unpin for ConversationHandler
impl UnsafeUnpin for ConversationHandler
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more