Skip to main content

ReadPlan

Struct ReadPlan 

Source
#[non_exhaustive]
pub struct ReadPlan { pub branch: Option<BranchId>, pub valid: Option<String>, pub recorded: Option<String>, pub limit: Option<usize>, }
Expand description

The lineage, the two instants, and the ceiling a read is taken under.

Every field is None by default and None means the same thing on all of them: the ordinary read. No branch is the trunk, no valid instant is now, no recorded instant is current belief, no limit is the whole answer. A default ReadPlan and no plan at all are the same read, which is what lets TraversalBuilder::plan be additive over the setters it composes rather than another way to configure a traversal.

§Why the branch is a BranchId and the instants are String

Not an oversight, and not symmetry withheld for its own sake. A branch name is validated at construction — length, control characters, surrounding whitespace — and BranchId is the type that has already asked those questions, so taking a String here would move a refusal out of the caller’s BranchId::new and into somewhere inside a read. A timestamp has no such type in this crate: the canonical form is enforced at the boundary (util::timestamps) and carried as a string everywhere below it, and inventing an instant newtype for one struct would give the crate two answers to what a stamp is. So Self::on cannot fail and neither can Self::valid_at; a malformed stamp is refused where every other stamp in the crate is refused.

§Errors, when this is executed

A plan is inert and returns nothing. The refusals belong to the read that takes one: DbError::UnknownBranch for a lineage that was never registered, and DbError::RecordedInstantUnreachable for a transaction-time instant the hot log no longer answers for (D-247).

use macrame::prelude::*;

let plan = ReadPlan::new()
    .on(BranchId::new("exp")?)
    .valid_at("2026-01-06T00:00:00.000000Z")
    .recorded_at("2026-03-01T00:00:00.000000Z");

// The same qualifiers, on a whole-ledger read and on a walk.
let edges = db.edges(plan.clone()).await?;
let reached = TraversalBuilder::new("a")
    .plan(plan)
    .execute_ids(db.read_conn(), "2026-06-01T00:00:00.000000Z")
    .await?;

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.
§branch: Option<BranchId>

The lineage to read, or None for the trunk (§15.3, D-220).

§valid: Option<String>

The valid-time instant: what was true then. None is now.

§recorded: Option<String>

The transaction-time instant: what did we believe then.

None is current belief, which is a projection read rather than a fold bounded at the present — the same answer, and only one of them is cheap. See TraversalBuilder::as_of_recorded.

§limit: Option<usize>

How much of the answer to pay for, or None for all of it (0.15.10, W13.5, C-8).

The one field that does not narrow which rows are true. The other three name a read; this one bounds it, so a plan carrying a limit describes an answer that is a prefix of the read rather than the read. What “prefix” means differs by surface and each says so: TraversalBuilder::limit() bounds the walk’s rows and returns the near end of the neighbourhood, Database::edges bounds its own statement and returns an arbitrary n of the ledger.

Implementations§

Source§

impl ReadPlan

Source

pub fn new() -> Self

The ordinary read: the trunk, now, under current belief.

Source

pub fn on(self, branch: BranchId) -> Self

Read branch’s belief rather than the trunk’s.

Source

pub fn valid_at(self, ts: impl Into<String>) -> Self

Read at a valid-time instant rather than the present.

Source

pub fn recorded_at(self, ts: impl Into<String>) -> Self

Read under the belief held at a transaction-time instant.

Source

pub fn limit(self, n: usize) -> Self

Pay for at most n rows (0.15.10, W13.5, C-8).

A ceiling on the read’s cost, not on which rows are true, and the two surfaces that take a plan spend it differently because their statements are different shapes. On a traversal it becomes TraversalBuilder::limit(), where it stops the recursion and yields the nodes nearest the start. On Database::edges it becomes a LIMIT on one flat projection, where the rows it keeps are whichever n the engine reaches first — that read states no order and adding one to make the truncation look principled would put a sort on the largest statement in the crate.

So a limited plan is honest about being a sample, and both surfaces let a caller tell that it was one: the traversal by WalkOutcome, and edges by returning exactly n, which is the ordinary convention because that statement drops nothing after the limit applies.

The method and the field share a name, as they do nowhere else on this struct. on/branch, valid_at/valid and recorded_at/recorded read as sentences and limit_to/limit does not; p.limit(5) and p.limit are unambiguous to the compiler and to a reader, and the spelling matches TraversalBuilder::limit(), which is where a caller meets the idea first.

Trait Implementations§

Source§

impl Clone for ReadPlan

Source§

fn clone(&self) -> ReadPlan

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 ReadPlan

Source§

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

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

impl Default for ReadPlan

Source§

fn default() -> ReadPlan

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

impl Eq for ReadPlan

Source§

impl PartialEq for ReadPlan

Source§

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

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

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ReadPlan

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<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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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<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<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<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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
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> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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