pub struct StreamHandle { /* private fields */ }Expand description
Minimal stream handle abstraction for long-lived streaming tasks.
Lifecycle contract:
- Prefer calling
stopto request a graceful shutdown and await completion. - Call
abortfor immediate, non-graceful termination. - If dropped without an explicit shutdown, a best-effort stop signal is sent (if available) and the underlying task is then aborted. The task may not observe the stop signal before abort.
Implementations§
Source§impl StreamHandle
impl StreamHandle
Sourcepub const fn new(inner: JoinHandle<()>, stop_tx: Sender<()>) -> Self
pub const fn new(inner: JoinHandle<()>, stop_tx: Sender<()>) -> Self
Create a new StreamHandle.
Parameters:
inner: the spawned task driving the stream.stop_tx: a one-shot used to request a graceful stop.
Returns a handle that can be used to stop or abort the stream.
Sourcepub const fn new_abort_only(inner: JoinHandle<()>) -> Self
pub const fn new_abort_only(inner: JoinHandle<()>) -> Self
Create a StreamHandle that can only abort the task (no graceful stop).
This constructor is intended for connectors that do not support a
cooperative shutdown signal. Dropping the handle (or calling
abort) will force-cancel the underlying task.
Trait Implementations§
Source§impl Debug for StreamHandle
impl Debug for StreamHandle
Auto Trait Implementations§
impl Freeze for StreamHandle
impl !RefUnwindSafe for StreamHandle
impl Send for StreamHandle
impl Sync for StreamHandle
impl Unpin for StreamHandle
impl !UnwindSafe for StreamHandle
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
Mutably borrows from an owned value. Read more