pub struct SessionView {
pub turns: BTreeMap<u32, Turn>,
pub request_to_turn: HashMap<u32, u32>,
/* private fields */
}Expand description
Client-side view of a session’s turn history.
Maps turn_id → Turn (ordered) and request_id → turn_id for
routing streaming chunks during an active agent loop.
Fields§
§turns: BTreeMap<u32, Turn>turn_id → Turn. Ordered by key (monotonically assigned by daemon).
request_to_turn: HashMap<u32, u32>request_id → turn_id for streaming chunk routing.
Inserted on Started, removed on Done/Failed/Cancelled.
Implementations§
Source§impl SessionView
impl SessionView
pub fn new() -> Self
pub fn insert_or_replace(&mut self, turn_id: u32, turn: Turn)
Sourcepub fn clear_tool_call_descriptions(&mut self, turn_id: u32)
pub fn clear_tool_call_descriptions(&mut self, turn_id: u32)
Drop the invocation-description entries for every call of turn_id.
Self::insert_or_replace cleans the map when the authoritative turn
replaces the accumulated one, but a request that fails mid-tool never
re-broadcasts its turn (Failed arrives with no final TurnAppended),
and a success whose final broadcast was dropped under load would
otherwise leak entries too. Callers invoke this from their
request-terminal handlers (handle_done / handle_failed) so the map
stays bounded by in-flight calls even on those paths.
pub fn get(&self, turn_id: u32) -> Option<&Turn>
pub fn get_mut(&mut self, turn_id: u32) -> Option<&mut Turn>
pub fn request_turn(&self, request_id: u32) -> Option<&Turn>
pub fn request_turn_mut(&mut self, request_id: u32) -> Option<&mut Turn>
Sourcepub fn stream_chunk(
&mut self,
request_id: u32,
stream: &OutputStream,
data: &str,
)
pub fn stream_chunk( &mut self, request_id: u32, stream: &OutputStream, data: &str, )
Route streaming output to the current turn for this request.
Sourcepub fn tool_call_started(
&mut self,
request_id: u32,
call_id: String,
name: String,
args: String,
invocation_description: &str,
)
pub fn tool_call_started( &mut self, request_id: u32, call_id: String, name: String, args: String, invocation_description: &str, )
Route a tool call start notification.
Sourcepub fn tool_result_chunk(&mut self, request_id: u32, call_id: &str, data: &str)
pub fn tool_result_chunk(&mut self, request_id: u32, call_id: &str, data: &str)
Route a tool result chunk — appends to the matching ToolResultRecord.
Creates a stub record if the ToolCallStarted event hasn’t arrived yet.
pub fn iter(&self) -> impl Iterator<Item = (&u32, &Turn)>
Trait Implementations§
Source§impl Clone for SessionView
impl Clone for SessionView
Source§impl Debug for SessionView
impl Debug for SessionView
Auto Trait Implementations§
impl Freeze for SessionView
impl RefUnwindSafe for SessionView
impl Send for SessionView
impl Sync for SessionView
impl Unpin for SessionView
impl UnsafeUnpin for SessionView
impl UnwindSafe for SessionView
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 moreimpl<T> JsonSchemaMaybe for T
impl<T> MaybeDebug for Twhere
T: Debug,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
Source§fn unchecked_into(self) -> T
fn unchecked_into(self) -> T
unchecked_from.