Skip to main content

ComputedView

Struct ComputedView 

Source
pub struct ComputedView<'a> { /* private fields */ }
Expand description

A stage’s read view of the store: typed reads, each checked at the access site against the reads the stage declared, with an optional catch-up store read before the run’s store.

The runner creates one view for each stage call and hands it to the stage inside the StageCx; a stage usually reads through StageCx::get, which reads through this view. Read a declared table with get or get_singleton. The view is Copy and borrows the store, so passing it around costs nothing.

Implementations§

Source§

impl<'a> ComputedView<'a>

Source

pub fn new( stage: &'a StageName, reads: &'a ReadSet, store: &'a Computed, ) -> ComputedView<'a>

Creates a view of store for stage, checked against reads.

Source

pub fn with_overlay(self, overlay: &'a Computed) -> ComputedView<'a>

Returns the same view, reading the catch-up store overlay before the run’s store: a table present in overlay is read from there, any other table from the run’s store.

A catch-up store shadows a table whole, never entry by entry. During value catch-up, the catch-up store holds the synthesized value’s own table piece of every table that the stages run over the value write, and a read of such a table returns that table piece alone, with none of the entries of the run’s store.

Consequently, a stage that runs during value catch-up and needs data about the whole document must read a table that the catch-up store can never hold, that is, a table that no per-tree stage (a stage of Scope::PerTree, run once for each tree) run during the catch-up writes. In practice, it is a table that a document-scope stage (a stage of Scope::Document, run once for the whole document) writes. The refs feature does so: its resolve stage reads REF_TARGETS, written once for the document, rather than the reference points of REFPOINTS, written per tree.

This rule is the reading side of the rule that StoreError::DocumentFactInValue enforces on the writing side: a synthesized value neither adds facts to the document nor reads them through a per-tree table.

See also StageCx::resolve_value and CaughtUp::view.

Source

pub fn stage(&self) -> &'a StageName

The stage whose reads this view checks.

Source

pub fn reads(&self) -> &'a ReadSet

The resolved reads that this view checks against.

Source

pub fn get<K: TableKey>( &self, key: K, ) -> Result<Option<&'a K::Table>, AccessError>

Reads a table that the stage declared as a read, through a typed table key.

Ok(None) means the table is not present, which happens only for an optional read that no stage of the plan provides: plan construction schedules a writer for every other read, and Run::new requires a value for every external table the plan needs.

§Errors

AccessError::UndeclaredRead if the stage did not declare a read of this table; AccessError::TypeMismatch if the value type of key is not the declared one.

§Panics

Panics if the table installed under this name holds a value of another type than the declared one. A stage cannot cause this: the declared type is checked here and when the table is written, and Run::new checks the type of every external table’s value before it installs it. The panic can only be reached through a Computed that a caller filled directly with Computed::install, which does not check the value type.

Source

pub fn get_singleton<T: SingletonTable>( &self, ) -> Result<Option<&'a T>, AccessError>

Reads the one table of a value type T that exactly one table uses (SingletonTable): get with the table name T::NAME.

§Errors

As for get.

§Panics

As for get.

Source

pub fn get_erased( &self, name: &str, ) -> Result<Option<&'a Arc<dyn Any + Send + Sync>>, AccessError>

Reads a table that the stage declared as a read, by name and type-erased, for a reader that has no Rust type for the value, such as a dump.

§Errors

AccessError::UndeclaredRead if the stage did not declare a read of this table. No type check applies, since the call gives no value type.

Source

pub fn producer_of(&self, name: &str) -> Option<&'a StageName>

Returns the stage that plan construction scheduled to write the table name, which this stage declared as a read. A diagnostic uses it to identify where a missing table entry should have come from (MissingEntry). None for an external table, for a table that no stage of the plan provides, and for a table that this stage did not declare as a read.

Trait Implementations§

Source§

impl<'a> Clone for ComputedView<'a>

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<'a> Copy for ComputedView<'a>

Source§

impl Debug for ComputedView<'_>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for ComputedView<'a>

§

impl<'a> !UnwindSafe for ComputedView<'a>

§

impl<'a> Forget for ComputedView<'a>

§

impl<'a> Freeze for ComputedView<'a>

§

impl<'a> Move for ComputedView<'a>

§

impl<'a> Send for ComputedView<'a>

§

impl<'a> Sync for ComputedView<'a>

§

impl<'a> Unpin for ComputedView<'a>

§

impl<'a> UnsafeUnpin for ComputedView<'a>

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

Source§

fn az<Dst>(self) -> Dst
where T: Cast<Dst>,

Casts the value.
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<Src, Dst> CastFrom<Src> for Dst
where Src: Cast<Dst>,

Source§

fn cast_from(src: Src) -> Dst

Casts the value.
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> CheckedAs for T

Source§

fn checked_as<Dst>(self) -> Option<Dst>
where T: CheckedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> CheckedCastFrom<Src> for Dst
where Src: CheckedCast<Dst>,

Source§

fn checked_cast_from(src: Src) -> Option<Dst>

Casts the value.
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> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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<Src, Dst> LosslessTryInto<Dst> for Src
where Dst: LosslessTryFrom<Src>,

Source§

fn lossless_try_into(self) -> Option<Dst>

Performs the conversion.
Source§

impl<Src, Dst> LossyInto<Dst> for Src
where Dst: LossyFrom<Src>,

Source§

fn lossy_into(self) -> Dst

Performs the conversion.
Source§

impl<T> OverflowingAs for T

Source§

fn overflowing_as<Dst>(self) -> (Dst, bool)
where T: OverflowingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> OverflowingCastFrom<Src> for Dst
where Src: OverflowingCast<Dst>,

Source§

fn overflowing_cast_from(src: Src) -> (Dst, bool)

Casts the value.
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> 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> SaturatingAs for T

Source§

fn saturating_as<Dst>(self) -> Dst
where T: SaturatingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> SaturatingCastFrom<Src> for Dst
where Src: SaturatingCast<Dst>,

Source§

fn saturating_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> StrictAs for T

Source§

fn strict_as<Dst>(self) -> Dst
where T: StrictCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> StrictCastFrom<Src> for Dst
where Src: StrictCast<Dst>,

Source§

fn strict_cast_from(src: Src) -> Dst

Casts the value.
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> UnwrappedAs for T

Source§

fn unwrapped_as<Dst>(self) -> Dst
where T: UnwrappedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> UnwrappedCastFrom<Src> for Dst
where Src: UnwrappedCast<Dst>,

Source§

fn unwrapped_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> WrappingAs for T

Source§

fn wrapping_as<Dst>(self) -> Dst
where T: WrappingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> WrappingCastFrom<Src> for Dst
where Src: WrappingCast<Dst>,

Source§

fn wrapping_cast_from(src: Src) -> Dst

Casts the value.