Skip to main content

Checkpoint

Struct Checkpoint 

Source
#[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
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§watermark: u64

The 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

Source

pub fn write_atomically(&self, path: &Path) -> Result<(), JournalError>

Available on crate feature 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.

Source

pub fn read(path: &Path) -> Result<Self, JournalError>

Available on crate feature 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

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn remaining<'a, I>( &'a self, targets: I, ) -> impl Iterator<Item = PlannedTarget> + 'a
where 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

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Checkpoint

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Checkpoint

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Checkpoint

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for Checkpoint

Source§

impl PartialEq for Checkpoint

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for Checkpoint

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Checkpoint

Auto Trait Implementations§

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<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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