pub struct CapturedOutput { /* private fields */ }Expand description
Bounded, incrementally-appended output capture shared (via Arc)
between a job’s stdout/stderr reader tasks and whatever later polls it
(background_status/background_list). Thread-safe; every method is
fail-soft on a poisoned lock (treats it as “temporarily unavailable”,
the same posture crate::permissions::approval::ApprovalCache already
documents for itself) rather than panicking a reader task or a tool
call.
Implementations§
Source§impl CapturedOutput
impl CapturedOutput
Sourcepub fn append(&self, chunk: &str, cap: usize)
pub fn append(&self, chunk: &str, cap: usize)
Append chunk, never growing the retained buffer past cap bytes —
bytes beyond the cap are DROPPED (fail-closed, never buffered) and
truncated latches true the first time that happens and stays
true thereafter. A caller must keep reading the underlying pipe past
this point regardless (to avoid blocking the child on a full,
undrained pipe) — this method only bounds what’s RETAINED in
memory, not what’s read off the pipe.
Sourcepub fn snapshot(&self) -> (String, bool)
pub fn snapshot(&self) -> (String, bool)
The full captured text so far, and whether it was ever truncated.
Sourcepub fn drain_new(&self) -> String
pub fn drain_new(&self) -> String
Text appended since the last drain_new call (or since creation, on
the first call) — the event-feed’s per-poll delta. Advances the
drain cursor even on an empty result, so polling twice in a row with
no new output between them returns "" the second time, never a
repeat of the first drain.