StreamHandle

Struct StreamHandle 

Source
pub struct StreamHandle { /* private fields */ }
Expand description

Minimal stream handle abstraction for long-lived streaming tasks.

Lifecycle contract:

  • Prefer calling stop to request a graceful shutdown and await completion.
  • Call abort for 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

Source

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.

Source

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.

Source

pub async fn stop(self)

Gracefully stop the underlying stream task and await its completion.

Sends a stop signal if available, then awaits the task. Any errors from the task are ignored.

Source

pub fn abort(self)

Force-abort the underlying stream task without waiting for completion.

Prefer stop when possible to allow cleanup.

Trait Implementations§

Source§

impl Debug for StreamHandle

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for StreamHandle

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.