pub struct ProvenanceTable { /* private fields */ }Expand description
Assigns EntityIds and remembers what each one came from.
One per document. Cloning it clones the whole history, which is what a rebuild-with-rollback needs.
Implementations§
Source§impl ProvenanceTable
impl ProvenanceTable
Sourcepub fn record(&mut self, provenance: Provenance) -> EntityId
pub fn record(&mut self, provenance: Provenance) -> EntityId
Record an entity’s provenance and return its identity.
§Panics
If more than u64::MAX - 1 entities are recorded. Not reachable.
Sourcepub fn primitive(&mut self, op: OpId, role: Role) -> EntityId
pub fn primitive(&mut self, op: OpId, role: Role) -> EntityId
Convenience for Provenance::Primitive.
Sourcepub fn derived(
&mut self,
op: OpId,
from: impl IntoIterator<Item = EntityId>,
role: Role,
) -> EntityId
pub fn derived( &mut self, op: OpId, from: impl IntoIterator<Item = EntityId>, role: Role, ) -> EntityId
Convenience for Provenance::Derived.
Sourcepub fn get(&self, id: EntityId) -> Option<&Provenance>
pub fn get(&self, id: EntityId) -> Option<&Provenance>
The provenance of id, or None if it belongs to another document.
Sourcepub fn roots(&self, id: EntityId) -> Vec<EntityId>
pub fn roots(&self, id: EntityId) -> Vec<EntityId>
Walk id’s derivation back to the entities it ultimately came from.
Returns the roots: entities that are Primitive or Imported. This is
how a stale reference is resolved after a rebuild: find what the user
originally picked, then find what that became.
Cycles cannot occur, because an entity can only be derived from ids that already existed when it was recorded. The visited set guards against a table assembled by hand or deserialized from a corrupt file.
Sourcepub fn iter(&self) -> impl Iterator<Item = (EntityId, &Provenance)>
pub fn iter(&self) -> impl Iterator<Item = (EntityId, &Provenance)>
Every entity, in the order its identity was issued.
For writing a document out: the table is the record of what every entity is, and a file that dropped it would come back as a model whose every reference had to be rebuilt from scratch.
Trait Implementations§
Source§impl Clone for ProvenanceTable
impl Clone for ProvenanceTable
Source§fn clone(&self) -> ProvenanceTable
fn clone(&self) -> ProvenanceTable
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more