Skip to main content

Source

Trait Source 

Source
pub trait Source: Send {
    // Required methods
    fn poll(&mut self, out: &mut Out) -> Poll;
    fn on_barrier(&mut self, epoch: u64) -> Vec<u8> ⓘ;

    // Provided methods
    fn position(&mut self) -> Vec<u8> ⓘ { ... }
    fn on_commit(&mut self, _epoch: u64) { ... }
    fn on_stop(&mut self) { ... }
}
Expand description

A source drives itself: the runtime calls poll until it returns Poll::Done (or the coordinator stops it).

Required Methods§

Source

fn poll(&mut self, out: &mut Out) -> Poll

Source

fn on_barrier(&mut self, epoch: u64) -> Vec<u8> ⓘ

A barrier for epoch: record the position the epoch covers; the bytes are the source’s own record of it, opaque to the runtime (a single-partition source writes it with position_record, the shape the checkpoint reads back).

Provided Methods§

Source

fn position(&mut self) -> Vec<u8> ⓘ

The position now, in the record on_barrier writes — read once when the source runs dry, so every checkpoint taken after it still names where it ended (a restore then resumes it there, past everything it emitted, instead of replaying it from the start). An unbounded source never runs dry: the default records nothing.

Source

fn on_commit(&mut self, _epoch: u64)

Every task reported epoch: the position recorded at its barrier may be committed.

Source

fn on_stop(&mut self)

The task is ending (the source ran dry, the coordinator stopped it, or it failed): the last chance to flush anything chained into this task.

Trait Implementations§

Source§

impl Source for Box<dyn Source>

Source§

fn poll(&mut self, out: &mut Out) -> Poll

Source§

fn on_barrier(&mut self, epoch: u64) -> Vec<u8> ⓘ

A barrier for epoch: record the position the epoch covers; the bytes are the source’s own record of it, opaque to the runtime (a single-partition source writes it with position_record, the shape the checkpoint reads back).
Source§

fn position(&mut self) -> Vec<u8> ⓘ

The position now, in the record on_barrier writes — read once when the source runs dry, so every checkpoint taken after it still names where it ended (a restore then resumes it there, past everything it emitted, instead of replaying it from the start). An unbounded source never runs dry: the default records nothing.
Source§

fn on_commit(&mut self, epoch: u64)

Every task reported epoch: the position recorded at its barrier may be committed.
Source§

fn on_stop(&mut self)

The task is ending (the source ran dry, the coordinator stopped it, or it failed): the last chance to flush anything chained into this task.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl Source for Box<dyn Source>

Source§

fn poll(&mut self, out: &mut Out) -> Poll

Source§

fn on_barrier(&mut self, epoch: u64) -> Vec<u8> ⓘ

Source§

fn position(&mut self) -> Vec<u8> ⓘ

Source§

fn on_commit(&mut self, epoch: u64)

Source§

fn on_stop(&mut self)

Implementors§

Source§

impl<S, K> Source for Chained<S, K>
where S: Source, K: Sink,