pub struct Inspector { /* private fields */ }Expand description
An inspector for stream data, inspecting it chunk by chunk.
See the inspect_* functions on BroadcastOutputStream and SingleOutputStream.
For proper cleanup, call
wait(), which waits for the collection task to complete.cancel(), which sends a termination signal and then waits for the collection task to complete.
If not cleaned up, the termination signal will be sent when dropping this inspector, but the task will be aborted (forceful, not waiting for its regular completion).
Implementations§
Source§impl Inspector
impl Inspector
Sourcepub fn is_finished(&self) -> bool
pub fn is_finished(&self) -> bool
Checks if this task has finished.
Sourcepub async fn wait(self) -> Result<(), InspectorError>
pub async fn wait(self) -> Result<(), InspectorError>
Wait for the inspector to terminate naturally.
An inspector will automatically terminate when either:
- The underlying write-side of the stream is dropped.
- The underlying stream is closed (by receiving an EOF / final read of 0 bytes).
- The first
Next::Breakis observed.
If none of these may occur in your case, this could/will hang forever!
§Errors
Returns InspectorError::TaskJoin if the inspector task cannot be joined.
§Panics
Panics if the inspector’s internal task has already been taken.
Sourcepub async fn cancel(self) -> Result<(), InspectorError>
pub async fn cancel(self) -> Result<(), InspectorError>
Sends a cancellation event to the inspector, letting it shut down.
§Errors
Returns InspectorError::TaskJoin if the inspector task cannot be joined.
§Panics
Panics if the inspector’s internal cancellation sender has already been taken.