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>
impl<'a> ComputedView<'a>
Sourcepub fn new(
stage: &'a StageName,
reads: &'a ReadSet,
store: &'a Computed,
) -> ComputedView<'a>
pub fn new( stage: &'a StageName, reads: &'a ReadSet, store: &'a Computed, ) -> ComputedView<'a>
Creates a view of store for stage, checked against reads.
Sourcepub fn with_overlay(self, overlay: &'a Computed) -> ComputedView<'a>
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.
Sourcepub fn get<K: TableKey>(
&self,
key: K,
) -> Result<Option<&'a K::Table>, AccessError>
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.
Sourcepub fn get_singleton<T: SingletonTable>(
&self,
) -> Result<Option<&'a T>, AccessError>
pub fn get_singleton<T: SingletonTable>( &self, ) -> Result<Option<&'a T>, AccessError>
Sourcepub fn get_erased(
&self,
name: &str,
) -> Result<Option<&'a Arc<dyn Any + Send + Sync>>, AccessError>
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.
Sourcepub fn producer_of(&self, name: &str) -> Option<&'a StageName>
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>
impl<'a> Clone for ComputedView<'a>
impl<'a> Copy for ComputedView<'a>
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> 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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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