pub trait CommandSource: Send + Sync {
type AckHandle: Send + Sync;
// Required methods
fn next<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<Option<Pulled<Self::AckHandle>>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn ack<'life0, 'async_trait>(
&'life0 self,
handle: Self::AckHandle,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn nack<'life0, 'async_trait>(
&'life0 self,
handle: Self::AckHandle,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
}Expand description
Pull-model command source.
next() returns:
Ok(Some(Pulled { outcome, ack }))— one pulled item. The caller inspectsoutcome(Claimed / AlreadyClaimed / RetryLater / Failed) and decides whether to callack(commit the pull) ornack(redeliver). Both ack and nack are required exactly once per pulled item.Ok(None)— the source is exhausted (local-mode playbook complete, mock source drained). Long-running sources (worker NATS) never returnNonein normal operation.Err(e)— transient or terminal source error before any pull happened; the caller’s retry policy decides whether to callnext()again.
§Lifecycle invariants
- Each
Pulled.ackhandle must be consumed exactly once viaack(handle)ornack(handle)before the nextnext()call in the same task. (Multiple concurrent next() calls are safe; each gets its own handle.) ackandnackare idempotent at the trait level — calling them multiple times on the same handle is undefined; the source impl may panic or treat the duplicate as a no-op.
Required Associated Types§
Required Methods§
Sourcefn next<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<Option<Pulled<Self::AckHandle>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn next<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<Option<Pulled<Self::AckHandle>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Pull one command from the source. See trait docs for return shape and lifecycle.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".