pub struct Stream<A: BaseTx, E: BaseRx, S: StateMarker> { /* private fields */ }Expand description
Handle to a running worker stream.
Wraps thread join handle, cancel token, health flag, action/event channels, and shared state.
Implementations§
Source§impl<A: BaseTx, E: BaseRx, S: StateMarker> Stream<A, E, S>
impl<A: BaseTx, E: BaseRx, S: StateMarker> Stream<A, E, S>
Sourcepub fn new(
id: Simple,
handle: JoinHandle<StreamResult<()>>,
health: HealthFlag,
action_tx: A,
event_rx: E,
state: Arc<StateCell<S>>,
cancel: CancelToken,
) -> Self
pub fn new( id: Simple, handle: JoinHandle<StreamResult<()>>, health: HealthFlag, action_tx: A, event_rx: E, state: Arc<StateCell<S>>, cancel: CancelToken, ) -> Self
Construct a new stream handle from parts.
Sourcepub fn token(&self) -> &CancelToken
pub fn token(&self) -> &CancelToken
Cancellation token of the stream.
Sourcepub fn is_healthy(&self) -> bool
pub fn is_healthy(&self) -> bool
Check current health flag.
Sourcepub fn is_cancelled(&self) -> bool
pub fn is_cancelled(&self) -> bool
Check if the cancel token is tripped.
Sourcepub fn stop(self) -> StreamResult<()>
pub fn stop(self) -> StreamResult<()>
Cancel and wait for the thread to end.
Sourcepub fn wait_to_end(self) -> StreamResult<()>
pub fn wait_to_end(self) -> StreamResult<()>
Wait for the thread to end, returning its result.
Source§impl<A, E, S> Stream<A, E, S>
impl<A, E, S> Stream<A, E, S>
Sourcepub fn try_send(
&mut self,
action: <A as BaseTx>::EventType,
) -> Result<(), SendError<<A as BaseTx>::EventType>>
pub fn try_send( &mut self, action: <A as BaseTx>::EventType, ) -> Result<(), SendError<<A as BaseTx>::EventType>>
Non-blocking send of an action into the worker.
Sourcepub fn send(
&mut self,
action: <A as BaseTx>::EventType,
timeout: Option<Duration>,
) -> Result<(), SendError<<A as BaseTx>::EventType>>
pub fn send( &mut self, action: <A as BaseTx>::EventType, timeout: Option<Duration>, ) -> Result<(), SendError<<A as BaseTx>::EventType>>
Send an action with optional timeout and cancellation.
Sourcepub fn action_tx_mut(&mut self) -> &mut A
pub fn action_tx_mut(&mut self) -> &mut A
Borrow the action TX half.
Trait Implementations§
Auto Trait Implementations§
impl<A, E, S> Freeze for Stream<A, E, S>
impl<A, E, S> !RefUnwindSafe for Stream<A, E, S>
impl<A, E, S> Send for Stream<A, E, S>
impl<A, E, S> Sync for Stream<A, E, S>
impl<A, E, S> Unpin for Stream<A, E, S>
impl<A, E, S> !UnwindSafe for Stream<A, E, S>
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request