pub struct LocalSessionCollector { /* private fields */ }Expand description
Collects this machine’s sessions for advertising to peers, keeping the per-session parse state that makes repeated collection cheap.
Deliberately a narrower path than App::refresh: it discovers, enriches and
reads token usage, but fires no hooks, sends no notifications and records no
history. relay serve runs alongside the TUI, and those side effects would
otherwise happen twice.
It is stateful for the same reason App is: sessions carry their JSONL read
offset, accumulated tokens and CPU history. Rebuilding them from scratch each
time would re-parse every transcript from byte zero on every collection —
seconds of work on a long session, on the relay’s own loop thread.
Implementations§
Source§impl LocalSessionCollector
impl LocalSessionCollector
pub fn new() -> Self
Sourcepub fn collect(&mut self) -> &[ClaudeSession]
pub fn collect(&mut self) -> &[ClaudeSession]
Refresh in place and return the current sessions. Surviving PIDs keep their previous session object, so JSONL reads stay incremental.
pub fn sessions(&self) -> &[ClaudeSession]
Sourcepub fn as_json(&self) -> Vec<Value>
pub fn as_json(&self) -> Vec<Value>
The sessions in the JSON shape peers parse with
ClaudeSession::from_remote_json.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for LocalSessionCollector
impl RefUnwindSafe for LocalSessionCollector
impl Send for LocalSessionCollector
impl Sync for LocalSessionCollector
impl Unpin for LocalSessionCollector
impl UnsafeUnpin for LocalSessionCollector
impl UnwindSafe for LocalSessionCollector
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
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