Skip to main content

Attach

Struct Attach 

Source
pub struct Attach<P: Phase, Prod: Producer, Cons: Consumer> { /* private fields */ }
Expand description

The typed attach handle. P is the current phase; the available methods are gated on P so malformed call sequences are compile errors rather than runtime mismatches.

Implementations§

Source§

impl<Prod, Cons> Attach<Spawned, Prod, Cons>
where Prod: Producer, Cons: Consumer<Item = Prod::Item, Snap = Prod::Snap>,

Source

pub fn builder() -> AttachConfigBuilder<Prod, Cons, ((), ())>

Public entry point — Attach::builder().

Source§

impl<Prod, Cons> Attach<Spawned, Prod, Cons>
where Prod: Producer, Cons: Consumer<Item = Prod::Item, Snap = Prod::Snap>,

Source

pub fn subscribe( self, ) -> Result<(Attach<Subscribed, Prod, Cons>, History<Prod::Snap>), AttachError>

Spawned → Subscribed. Subscribe to the live stream FIRST (so no item between subscribe and snapshot is lost), then capture the snapshot. Returns the new phase + a History handle that must be passed to replay (drop-bomb prevents forgetting).

Source§

impl<Prod, Cons> Attach<Subscribed, Prod, Cons>
where Prod: Producer, Cons: Consumer<Item = Prod::Item, Snap = Prod::Snap>,

Source

pub fn replay( self, history: History<Prod::Snap>, ) -> Result<Attach<Synced, Prod, Cons>, AttachError>

Subscribed → Synced. Consumes the History handle and replays the snapshot into the consumer. History is moved (not borrowed) so the type system enforces “exactly once”.

Source§

impl<Prod, Cons> Attach<Synced, Prod, Cons>
where Prod: Producer, Cons: Consumer<Item = Prod::Item, Snap = Prod::Snap>,

Source

pub fn start_live(self) -> Attach<Live, Prod, Cons>

Synced → Live. Items queued in the live receiver since subscribe begin flowing into the consumer. Returns Attach<Live> — the only phase from which run is reachable.

Source§

impl<Prod, Cons> Attach<Live, Prod, Cons>
where Prod: Producer, Cons: Consumer<Item = Prod::Item, Snap = Prod::Snap>,

Source

pub fn run(self) -> Cons

Drain the live receiver synchronously, forwarding each item to the consumer. Blocks until the producer drops its sender (clean closure) or the receiver errors. Returns the consumer so the caller can inspect terminal state.

Source

pub fn poll_one(&mut self) -> bool

Non-blocking single-item drain. Returns true if an item was consumed; false if the channel is empty or closed. Useful for embedding the drain inside an existing event loop (winit, tokio task, etc.) instead of dedicating a thread.

Auto Trait Implementations§

§

impl<P, Prod, Cons> !Sync for Attach<P, Prod, Cons>

§

impl<P, Prod, Cons> Freeze for Attach<P, Prod, Cons>
where Prod: Freeze, Cons: Freeze,

§

impl<P, Prod, Cons> RefUnwindSafe for Attach<P, Prod, Cons>
where Prod: RefUnwindSafe, Cons: RefUnwindSafe, P: RefUnwindSafe,

§

impl<P, Prod, Cons> Send for Attach<P, Prod, Cons>

§

impl<P, Prod, Cons> Unpin for Attach<P, Prod, Cons>
where Prod: Unpin, Cons: Unpin, P: Unpin,

§

impl<P, Prod, Cons> UnsafeUnpin for Attach<P, Prod, Cons>
where Prod: UnsafeUnpin, Cons: UnsafeUnpin,

§

impl<P, Prod, Cons> UnwindSafe for Attach<P, Prod, Cons>
where Prod: UnwindSafe, Cons: UnwindSafe, P: UnwindSafe,

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more