#[non_exhaustive]pub struct Checkpoint {
pub watermark: u64,
pub settled_above: Vec<u64>,
pub walked: Option<Walked>,
}Expand description
A cursor as it is written down.
Two watermarks and the positions neither has reached. Settled in either order the scan counts in, that is a handful of positions however large the plan.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.watermark: u64The position below which everything is settled.
settled_above: Vec<u64>Settled positions at or above the watermark that the walk has not reached, ascending.
Ascending is an invariant: is_settled binary-searches it.
new establishes it, and read re-establishes it on anything
read from a file.
walked: Option<Walked>How far along the order the scan asks in everything is settled, for a scan that counted along one.
Absent from a checkpoint of a scan that was not walked, or from an older engine. An older engine reads a checkpoint carrying one as having settled less, which costs probes and skips nothing.
Implementations§
Source§impl Checkpoint
impl Checkpoint
Sourcepub fn write_atomically(&self, path: &Path) -> Result<(), JournalError>
Available on crate feature journal-format only.
pub fn write_atomically(&self, path: &Path) -> Result<(), JournalError>
journal-format only.Writes the checkpoint so that a process killed mid-write leaves the previous one intact.
Writes a sibling temporary file and renames it over the destination, which is atomic on
every filesystem this engine runs on, so a reader sees one whole checkpoint or the one
before. No fsync: ^C, a dropped session and an OOM kill are process deaths, and the
page cache outlives the process. See journal.
Sourcepub fn read(path: &Path) -> Result<Self, JournalError>
Available on crate feature journal-format only.
pub fn read(path: &Path) -> Result<Self, JournalError>
journal-format only.Reads a checkpoint back.
The settled_above list is sorted on read, since
is_settled binary-searches it and an unsorted list would
miss a position that is present and re-probe a settled target.
Source§impl Checkpoint
impl Checkpoint
Sourcepub fn new(watermark: u64, settled_above: impl IntoIterator<Item = u64>) -> Self
pub fn new(watermark: u64, settled_above: impl IntoIterator<Item = u64>) -> Self
A checkpoint over watermark and the settled positions above it.
Sorts and deduplicates the list, the invariant is_settled
relies on. The fields are public, but this is the way that cannot build one wrong, and a
caller storing journals somewhere other than a directory should use it.
Sourcepub fn is_settled(&self, position: u64) -> bool
pub fn is_settled(&self, position: u64) -> bool
Whether the target at position may be skipped.
Binary-searched, so settled_above must be ascending;
new guarantees that.
Sourcepub fn settled_count(&self) -> u64
pub fn settled_count(&self) -> u64
How many targets are settled in total.
Read without walking: the watermark, what the walk counted past it, and the
positions neither reached. A listed position a watermark has passed is counted once, as
Cursor::from_checkpoint reads the same file.
Sourcepub fn remaining_addresses(&self, positions: &Positions) -> IpSet
pub fn remaining_addresses(&self, positions: &Positions) -> IpSet
The addresses a resumed sweep still has to ask about.
The sweep counterpart of remaining. Returns a set because a
HostScanner owns its targets and its positions
come from the context; see
ScanContext::settle_address,
which numbers an address against this same plan.
Computed from the ranges: everything below the watermark is one span to drop, and the positions settled out of order above it are taken out individually. Anything the plan was too large to number comes back whole.
positions must number the plan this checkpoint was written against; the manifest’s
plan fingerprint refuses a mismatched resume before it gets here.
Sourcepub fn remaining<'a, I>(
&'a self,
targets: I,
) -> impl Iterator<Item = PlannedTarget> + 'awhere
I: IntoIterator<Item = Target> + 'a,
pub fn remaining<'a, I>(
&'a self,
targets: I,
) -> impl Iterator<Item = PlannedTarget> + 'awhere
I: IntoIterator<Item = Target> + 'a,
The targets a resumed scan still has to ask about, each carrying its position in the original plan.
Takes the plan’s enumeration,
TargetMap::iter, the walk the first sitting
was numbered by, and yields only what this checkpoint does not account for.
Yields PlannedTarget so the original numbering survives the filtering: numbering the
subset afresh would give position 0 to whatever is left, and the two sittings’ cursors
would count different things.
The plan must be the one this checkpoint was written against. A changed port list, exclusion policy or privilege level moves what each position refers to. Nothing here detects that; the manifest’s plan fingerprint refuses the resume first.
Trait Implementations§
Source§impl Clone for Checkpoint
impl Clone for Checkpoint
Source§impl Debug for Checkpoint
impl Debug for Checkpoint
Source§impl Default for Checkpoint
impl Default for Checkpoint
Source§impl<'de> Deserialize<'de> for Checkpoint
impl<'de> Deserialize<'de> for Checkpoint
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for Checkpoint
Source§impl PartialEq for Checkpoint
impl PartialEq for Checkpoint
Source§impl Serialize for Checkpoint
impl Serialize for Checkpoint
impl StructuralPartialEq for Checkpoint
Auto Trait Implementations§
impl Freeze for Checkpoint
impl RefUnwindSafe for Checkpoint
impl Send for Checkpoint
impl Sync for Checkpoint
impl Unpin for Checkpoint
impl UnsafeUnpin for Checkpoint
impl UnwindSafe for Checkpoint
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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