pub trait ShellOutputObserver:
Send
+ Sync
+ 'static {
// Required method
fn on_output(
&self,
invocation: ShellInvocationId,
stream: ShellOutputStream,
chunk: &[u8],
);
// Provided method
fn on_finish(&self, _invocation: ShellInvocationId) { ... }
}Expand description
Receives bounded shell output while a tool invocation is still running.
Chunks contain raw bytes and may split a UTF-8 code point. Calls run on a dedicated presentation thread, never a child pipe-draining thread, so a slow observer cannot stall the child or the invocation timeout. A single pipe remains in read order; ordering between stdout, stderr, and separate pipeline-stage stderr pipes follows live enqueue scheduling. Calls for one invocation are serialized on its presentation thread. Separate invocations use separate presentation threads and may call the same observer concurrently, so implementations must synchronize shared state.
The per-stream budget bounds live delivery, but it does not redefine the
completed result. In particular, safe-shell pipeline stderr readers race for
the shared live budget, while the final envelope concatenates stderr in
pipeline-stage order and then applies its cap. Observed bytes can therefore
differ from the final stderr; the envelope is authoritative.
Observation is presentation-only and grants no authority. A callback panic
is contained and disables observation for that invocation; it never changes
the shell result. Normal completion asynchronously drains chunks already
queued within the output cap, then calls ShellOutputObserver::on_finish.
Cancellation or timeout stops accepting chunks immediately and does not call
on_finish, but a callback already dequeued by the presentation thread may
begin or finish after the invocation future returns.
Required Methods§
Sourcefn on_output(
&self,
invocation: ShellInvocationId,
stream: ShellOutputStream,
chunk: &[u8],
)
fn on_output( &self, invocation: ShellInvocationId, stream: ShellOutputStream, chunk: &[u8], )
Observe a non-empty raw output chunk from stream.
Provided Methods§
Sourcefn on_finish(&self, _invocation: ShellInvocationId)
fn on_finish(&self, _invocation: ShellInvocationId)
Report that an ordinarily completed invocation has delivered every output callback queued before completion.
This runs on the same presentation thread after all prior on_output
calls for invocation. Tool dispatch does not wait for it. It is not
called after cancellation, timeout, or an observer panic.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".