pub struct EngineHandle<E> { /* private fields */ }Expand description
A running engine, reachable from outside its drive.
Cheap to clone: both halves are channel senders. Cloning does not keep the
engine alive — the drive ends when its policy says so, and every handle then
reports EngineGone.
Implementations§
Source§impl<E> EngineHandle<E>
impl<E> EngineHandle<E>
Sourcepub const fn new(inbox: Sender<Msg>, events: Sender<E>) -> Self
pub const fn new(inbox: Sender<Msg>, events: Sender<E>) -> Self
Wrap an existing pair. The daemon supplies its own event bus, because it has to subscribe before the run starts to catch the line that names the session.
Sourcepub fn with_capacity(inbox: Sender<Msg>, capacity: usize) -> Selfwhere
E: Clone,
pub fn with_capacity(inbox: Sender<Msg>, capacity: usize) -> Selfwhere
E: Clone,
Wrap an inbox with a fresh event bus of capacity.
Sourcepub async fn send(&self, msg: Msg) -> Result<(), EngineGone>
pub async fn send(&self, msg: Msg) -> Result<(), EngineGone>
Deliver a message to the running engine.
Awaits a slot when the inbox is full: that is backpressure from a run
that is behind on its own effects, and dropping the message instead
would lose a user’s prompt. Use EngineHandle::try_send where the
caller cannot wait.
§Errors
EngineGone once the drive has ended.
Sourcepub fn try_send(&self, msg: Msg) -> Result<(), EngineGone>
pub fn try_send(&self, msg: Msg) -> Result<(), EngineGone>
Deliver without waiting. Reports EngineGone for a finished engine
and, for a full inbox, hands the message back the same way — a caller
that cannot wait cannot queue either.
§Errors
EngineGone when the drive has ended or its inbox is full.
Sourcepub fn subscribe(&self) -> Receiver<E>
pub fn subscribe(&self) -> Receiver<E>
Watch what the engine’s observer publishes, from now on.
A subscriber that needs what it missed reads the session event log first
and then joins here — the shape subscribe_task already uses, and the
reason this is a broadcast and not a replayable stream.
Sourcepub const fn publisher(&self) -> &Sender<E>
pub const fn publisher(&self) -> &Sender<E>
The publishing end, for whatever observer feeds this handle.
Sourcepub fn is_running(&self) -> bool
pub fn is_running(&self) -> bool
Whether the drive is still pumping. Racy by nature — a run can end
between the check and the send, which is why EngineHandle::send
reports it too.
Trait Implementations§
Source§impl<E> Clone for EngineHandle<E>
impl<E> Clone for EngineHandle<E>
Auto Trait Implementations§
impl<E> !RefUnwindSafe for EngineHandle<E>
impl<E> !UnwindSafe for EngineHandle<E>
impl<E> Freeze for EngineHandle<E>
impl<E> Send for EngineHandle<E>where
E: Send,
impl<E> Sync for EngineHandle<E>where
E: Send,
impl<E> Unpin for EngineHandle<E>
impl<E> UnsafeUnpin for EngineHandle<E>
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more