pub trait Triplets: NamedTypeLinks {
Show 13 methods
// Required method
fn triplet_markers(&self) -> TripletMarkers;
// Provided methods
fn role_of(&mut self, id: u32) -> Option<DoubletRole> { ... }
fn get_triplet(&mut self, index: u32) -> Option<Triplet> { ... }
fn is_triplet(&mut self, index: u32) -> bool { ... }
fn reference_is_triplet(&mut self, index: u32) -> bool { ... }
fn create_triplet(
&mut self,
type_id: u32,
from: u32,
to: u32,
) -> Result<u32> { ... }
fn create_triplet_point(&mut self) -> Result<u32> { ... }
fn create_triplet_point_at(&mut self, address: u32) -> Result<()> { ... }
fn update_triplet(
&mut self,
index: u32,
type_id: u32,
from: u32,
to: u32,
) -> Result<Triplet> { ... }
fn delete_triplet(&mut self, index: u32) -> Result<Vec<Triplet>> { ... }
fn each_triplet(&mut self, query: TripletQuery) -> Vec<Triplet> { ... }
fn count_triplets(&mut self, query: TripletQuery) -> usize { ... }
fn doublet_usages(&mut self, id: u32) -> usize { ... }
}Expand description
The reads and writes of triplets stored in doublets.
Only triplet_markers is required; everything
else is a default method that reads and writes through Self, so a layer
that wraps a TripletsOverDoublets can implement this trait by forwarding
the markers and see every doublet the encoding writes. Any default can be
overridden: PermissionsDecorator checks a
triplet as a whole, above the wrappers and pairs it is stored in.
The names end in triplet because a triplet store is still a doublet
store: create, update and delete of NamedTypeLinks keep working
on the doublets underneath.
Required Methods§
Sourcefn triplet_markers(&self) -> TripletMarkers
fn triplet_markers(&self) -> TripletMarkers
The markers of the encoding.
Provided Methods§
Sourcefn role_of(&mut self, id: u32) -> Option<DoubletRole>
fn role_of(&mut self, id: u32) -> Option<DoubletRole>
What the doublet id is in the encoding; None when it is missing.
Sourcefn get_triplet(&mut self, index: u32) -> Option<Triplet>
fn get_triplet(&mut self, index: u32) -> Option<Triplet>
The triplet at index, None when index is not a triplet.
Sourcefn is_triplet(&mut self, index: u32) -> bool
fn is_triplet(&mut self, index: u32) -> bool
Whether index is a triplet.
Sourcefn reference_is_triplet(&mut self, index: u32) -> bool
fn reference_is_triplet(&mut self, index: u32) -> bool
Whether a reference to index names a triplet: the same as
Self::is_triplet, but for a view that hides triplets, where one the
subject may refer to counts as well (issue #161).
Sourcefn create_triplet(&mut self, type_id: u32, from: u32, to: u32) -> Result<u32>
fn create_triplet(&mut self, type_id: u32, from: u32, to: u32) -> Result<u32>
Creates (i: type from to) and returns i.
type must be a triplet; from and to must be triplets or 0.
Sourcefn create_triplet_point(&mut self) -> Result<u32>
fn create_triplet_point(&mut self) -> Result<u32>
Creates a triplet (i: i 0 0) that is its own type: the root of a
hierarchy has to start somewhere.
Sourcefn create_triplet_point_at(&mut self, address: u32) -> Result<()>
fn create_triplet_point_at(&mut self, address: u32) -> Result<()>
Creates the point (address: address 0 0) at an address nothing uses,
the way a substitution query defines a triplet at an address it names.
Sourcefn update_triplet(
&mut self,
index: u32,
type_id: u32,
from: u32,
to: u32,
) -> Result<Triplet>
fn update_triplet( &mut self, index: u32, type_id: u32, from: u32, to: u32, ) -> Result<Triplet>
Makes the triplet at index (index: type from to), keeping its
address, and returns the triplet as it was.
type must be a triplet or index itself; from and to must be
triplets, index itself or 0. The pair the triplet no longer uses is
collected when nothing else uses it.
Sourcefn delete_triplet(&mut self, index: u32) -> Result<Vec<Triplet>>
fn delete_triplet(&mut self, index: u32) -> Result<Vec<Triplet>>
Deletes the triplet at index and every triplet that uses a deleted
one as its type, from or to; returns them all, index first.
Wrappers and pairs nothing uses any more are collected, so no doublet is left behind.
Sourcefn each_triplet(&mut self, query: TripletQuery) -> Vec<Triplet>
fn each_triplet(&mut self, query: TripletQuery) -> Vec<Triplet>
The triplets that match query, in the order of their addresses.
A restriction by index is one lookup; by from (and to) it goes through the wrapper of the from-part and its pairs, by to through the pairs that end at it, by type through the doublets whose source is the type. Only a query that restricts none of them, or only an empty from or to, reads every doublet.
Sourcefn count_triplets(&mut self, query: TripletQuery) -> usize
fn count_triplets(&mut self, query: TripletQuery) -> usize
The number of triplets that match query.
Sourcefn doublet_usages(&mut self, id: u32) -> usize
fn doublet_usages(&mut self, id: u32) -> usize
How many other doublets use the doublet id as their source or target.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementations on Foreign Types§
Source§impl<T: Triplets + ?Sized> Triplets for &mut T
A store lent to a layer above stays a store of triplets, as it stays
NamedTypeLinks.
impl<T: Triplets + ?Sized> Triplets for &mut T
A store lent to a layer above stays a store of triplets, as it stays
NamedTypeLinks.