pub struct Persisted<P>where
P: Persistence,{ /* private fields */ }sleep only.Expand description
A backend that drives a Persistence instance to emit tasks
This provides a lightweight way to compose a backend without worrying about polling
Implementations§
Source§impl<P> Persisted<P>
impl<P> Persisted<P>
Sourcepub fn new(inner: P) -> Self
pub fn new(inner: P) -> Self
Creates a new Persisted in the NotBootstrapped state.
The worker will register itself with the backend on the first call
to poll_ready.
Sourcepub fn layer<C>(
&mut self,
codec: C,
batch_size: usize,
) -> TaskPersistLayer<C, P::Response>
pub fn layer<C>( &mut self, codec: C, batch_size: usize, ) -> TaskPersistLayer<C, P::Response>
Build a layer that wraps a TaskPersistLayer
Sourcepub fn poll_ready(
&mut self,
cx: &mut Context<'_>,
worker: &WorkerContext,
heartbeat_interval: Duration,
) -> Poll<Result<(), P::Error>>
pub fn poll_ready( &mut self, cx: &mut Context<'_>, worker: &WorkerContext, heartbeat_interval: Duration, ) -> Poll<Result<(), P::Error>>
Drives the provider’s internal state machine (bootstrap, heartbeat,
event processing) until it is genuinely ready for poll_next
to be called, or until it must return Pending.
Sourcepub fn poll_next(
&mut self,
cx: &mut Context<'_>,
worker: &WorkerContext,
) -> Poll<Option<Result<Task<P::Compact>, P::Error>>>
pub fn poll_next( &mut self, cx: &mut Context<'_>, worker: &WorkerContext, ) -> Poll<Option<Result<Task<P::Compact>, P::Error>>>
Pulls the next task from the backend, fetching a fresh batch when the internal buffer is exhausted.
Assumes poll_ready has already driven the state
machine into State::Ready; other states fall through to Pending
since they’re the responsibility of poll_ready/poll_close.
Sourcepub fn poll_close(
&mut self,
cx: &mut Context<'_>,
worker: &WorkerContext,
) -> Poll<Result<(), P::Error>>
pub fn poll_close( &mut self, cx: &mut Context<'_>, worker: &WorkerContext, ) -> Poll<Result<(), P::Error>>
Gracefully winds down the provider: finishes in-flight bootstrap/heartbeat event futures, re-enqueues any abandoned buffered tasks, then flushes remaining events before signalling completion.
Trait Implementations§
Source§impl<P> Deref for Persisted<P>where
P: Persistence,
impl<P> Deref for Persisted<P>where
P: Persistence,
Source§impl<P> DerefMut for Persisted<P>where
P: Persistence,
impl<P> DerefMut for Persisted<P>where
P: Persistence,
Source§impl<P> Sink<Task<<P as Persistence>::Compact>> for Persisted<P>
impl<P> Sink<Task<<P as Persistence>::Compact>> for Persisted<P>
Source§type Error = <P as Persistence>::Error
type Error = <P as Persistence>::Error
Source§fn poll_ready(
self: Pin<&mut Self>,
_cx: &mut Context<'_>,
) -> Poll<Result<(), Self::Error>>
fn poll_ready( self: Pin<&mut Self>, _cx: &mut Context<'_>, ) -> Poll<Result<(), Self::Error>>
Sink to receive a value. Read moreSource§fn start_send(
self: Pin<&mut Self>,
item: Task<P::Compact>,
) -> Result<(), Self::Error>
fn start_send( self: Pin<&mut Self>, item: Task<P::Compact>, ) -> Result<(), Self::Error>
poll_ready which returned Poll::Ready(Ok(())). Read moreAuto Trait Implementations§
impl<P> !Freeze for Persisted<P>
impl<P> !RefUnwindSafe for Persisted<P>
impl<P> !UnwindSafe for Persisted<P>
impl<P> Send for Persisted<P>where
State<Task<<P as Persistence>::Compact>, <P as Persistence>::Error>: Send,
Option<Receiver<TaskEvent<<P as Persistence>::Response>>>: Send,
Vec<Task<<P as Persistence>::Compact>>: Send,
Option<BoxSyncFuture<Result<(), <P as Persistence>::Error>>>: Send,
impl<P> Sync for Persisted<P>where
P: Sync,
State<Task<<P as Persistence>::Compact>, <P as Persistence>::Error>: Sync,
Option<Receiver<TaskEvent<<P as Persistence>::Response>>>: Sync,
Vec<Task<<P as Persistence>::Compact>>: Sync,
Option<BoxSyncFuture<Result<(), <P as Persistence>::Error>>>: Sync,
impl<P> Unpin for Persisted<P>where
P: Unpin,
State<Task<<P as Persistence>::Compact>, <P as Persistence>::Error>: Unpin,
Option<Receiver<TaskEvent<<P as Persistence>::Response>>>: Unpin,
Vec<Task<<P as Persistence>::Compact>>: Unpin,
Option<BoxSyncFuture<Result<(), <P as Persistence>::Error>>>: Unpin,
impl<P> UnsafeUnpin for Persisted<P>where
P: UnsafeUnpin,
State<Task<<P as Persistence>::Compact>, <P as Persistence>::Error>: UnsafeUnpin,
Option<Receiver<TaskEvent<<P as Persistence>::Response>>>: UnsafeUnpin,
Vec<Task<<P as Persistence>::Compact>>: UnsafeUnpin,
Option<BoxSyncFuture<Result<(), <P as Persistence>::Error>>>: UnsafeUnpin,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<R> CryptoRng for R
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> ⓘ
impl<R> RngCore for Rwhere
R: Rng,
Source§impl<R> RngExt for R
impl<R> RngExt for R
Source§fn random<T>(&mut self) -> Twhere
StandardUniform: Distribution<T>,
fn random<T>(&mut self) -> Twhere
StandardUniform: Distribution<T>,
StandardUniform distribution. Read moreSource§fn random_iter<T>(self) -> Iter<StandardUniform, Self, T> ⓘ
fn random_iter<T>(self) -> Iter<StandardUniform, Self, T> ⓘ
Source§fn random_range<T, R>(&mut self, range: R) -> Twhere
T: SampleUniform,
R: SampleRange<T>,
fn random_range<T, R>(&mut self, range: R) -> Twhere
T: SampleUniform,
R: SampleRange<T>,
Source§fn random_bool(&mut self, p: f64) -> bool
fn random_bool(&mut self, p: f64) -> bool
p of being true. Read moreSource§fn random_ratio(&mut self, numerator: u32, denominator: u32) -> bool
fn random_ratio(&mut self, numerator: u32, denominator: u32) -> bool
numerator/denominator of being
true. Read moreSource§fn sample<T, D>(&mut self, distr: D) -> Twhere
D: Distribution<T>,
fn sample<T, D>(&mut self, distr: D) -> Twhere
D: Distribution<T>,
Source§fn sample_iter<T, D>(self, distr: D) -> Iter<D, Self, T> ⓘwhere
D: Distribution<T>,
Self: Sized,
fn sample_iter<T, D>(self, distr: D) -> Iter<D, Self, T> ⓘwhere
D: Distribution<T>,
Self: Sized,
Source§impl<T, Item> SinkExt<Item> for T
impl<T, Item> SinkExt<Item> for T
Source§fn with<U, Fut, F, E>(self, f: F) -> With<Self, Item, U, Fut, F>
fn with<U, Fut, F, E>(self, f: F) -> With<Self, Item, U, Fut, F>
Source§fn with_flat_map<U, St, F>(self, f: F) -> WithFlatMap<Self, Item, U, St, F>
fn with_flat_map<U, St, F>(self, f: F) -> WithFlatMap<Self, Item, U, St, F>
Source§fn sink_map_err<E, F>(self, f: F) -> SinkMapErr<Self, F>
fn sink_map_err<E, F>(self, f: F) -> SinkMapErr<Self, F>
Source§fn sink_err_into<E>(self) -> SinkErrInto<Self, Item, E>
fn sink_err_into<E>(self) -> SinkErrInto<Self, Item, E>
Into trait. Read moreSource§fn buffer(self, capacity: usize) -> Buffer<Self, Item>where
Self: Sized,
fn buffer(self, capacity: usize) -> Buffer<Self, Item>where
Self: Sized,
alloc only.Source§fn flush(&mut self) -> Flush<'_, Self, Item> ⓘwhere
Self: Unpin,
fn flush(&mut self) -> Flush<'_, Self, Item> ⓘwhere
Self: Unpin,
Source§fn send(&mut self, item: Item) -> Send<'_, Self, Item> ⓘwhere
Self: Unpin,
fn send(&mut self, item: Item) -> Send<'_, Self, Item> ⓘwhere
Self: Unpin,
Source§fn feed(&mut self, item: Item) -> Feed<'_, Self, Item> ⓘwhere
Self: Unpin,
fn feed(&mut self, item: Item) -> Feed<'_, Self, Item> ⓘwhere
Self: Unpin,
Source§fn send_all<'a, St>(&'a mut self, stream: &'a mut St) -> SendAll<'a, Self, St> ⓘ
fn send_all<'a, St>(&'a mut self, stream: &'a mut St) -> SendAll<'a, Self, St> ⓘ
Source§fn right_sink<Si1>(self) -> Either<Si1, Self> ⓘ
fn right_sink<Si1>(self) -> Either<Si1, Self> ⓘ
Source§fn poll_ready_unpin(
&mut self,
cx: &mut Context<'_>,
) -> Poll<Result<(), Self::Error>>where
Self: Unpin,
fn poll_ready_unpin(
&mut self,
cx: &mut Context<'_>,
) -> Poll<Result<(), Self::Error>>where
Self: Unpin,
Sink::poll_ready on Unpin
sink types.Source§fn start_send_unpin(&mut self, item: Item) -> Result<(), Self::Error>where
Self: Unpin,
fn start_send_unpin(&mut self, item: Item) -> Result<(), Self::Error>where
Self: Unpin,
Sink::start_send on Unpin
sink types.