[][src]Trait terminus_store::Layer

pub trait Layer: Send + Sync {
    fn name(&self) -> [u32; 5];
fn parent(&self) -> Option<&dyn Layer>;
fn node_and_value_count(&self) -> usize;
fn predicate_count(&self) -> usize;
fn predicate_dict_get(&self, id: usize) -> Option<String>;
fn predicate_dict_len(&self) -> usize;
fn predicate_dict_id(&self, predicate: &str) -> Option<u64>;
fn node_dict_id(&self, subject: &str) -> Option<u64>;
fn node_dict_get(&self, id: usize) -> Option<String>;
fn node_dict_len(&self) -> usize;
fn value_dict_id(&self, value: &str) -> Option<u64>;
fn value_dict_len(&self) -> usize;
fn value_dict_get(&self, id: usize) -> Option<String>;
fn subject_id(&self, subject: &str) -> Option<u64>;
fn predicate_id(&self, predicate: &str) -> Option<u64>;
fn object_node_id(&self, object: &str) -> Option<u64>;
fn object_value_id(&self, object: &str) -> Option<u64>;
fn id_subject(&self, id: u64) -> Option<String>;
fn id_predicate(&self, id: u64) -> Option<String>;
fn id_object(&self, id: u64) -> Option<ObjectType>;
fn subject_additions(
        &self
    ) -> Box<dyn Iterator<Item = Box<dyn LayerSubjectLookup>>>;
fn subject_removals(
        &self
    ) -> Box<dyn Iterator<Item = Box<dyn LayerSubjectLookup>>>;
fn lookup_subject_addition(
        &self,
        subject: u64
    ) -> Option<Box<dyn LayerSubjectLookup>>;
fn lookup_subject_removal(
        &self,
        subject: u64
    ) -> Option<Box<dyn LayerSubjectLookup>>;
fn object_additions(
        &self
    ) -> Box<dyn Iterator<Item = Box<dyn LayerObjectLookup>>>;
fn object_removals(
        &self
    ) -> Box<dyn Iterator<Item = Box<dyn LayerObjectLookup>>>;
fn lookup_object_addition(
        &self,
        object: u64
    ) -> Option<Box<dyn LayerObjectLookup>>;
fn lookup_object_removal(
        &self,
        object: u64
    ) -> Option<Box<dyn LayerObjectLookup>>;
fn lookup_predicate_addition(
        &self,
        predicate: u64
    ) -> Option<Box<dyn LayerPredicateLookup>>;
fn lookup_predicate_removal(
        &self,
        predicate: u64
    ) -> Option<Box<dyn LayerPredicateLookup>>;
fn clone_boxed(&self) -> Box<dyn Layer>; fn subjects(&self) -> Box<dyn Iterator<Item = Box<dyn SubjectLookup>>> { ... }
fn lookup_subject(&self, subject: u64) -> Option<Box<dyn SubjectLookup>> { ... }
fn objects(&self) -> Box<dyn Iterator<Item = Box<dyn ObjectLookup>>> { ... }
fn lookup_object(&self, object: u64) -> Option<Box<dyn ObjectLookup>> { ... }
fn lookup_predicate(
        &self,
        predicate: u64
    ) -> Option<Box<dyn PredicateLookup>> { ... }
fn all_counts(&self) -> LayerCounts { ... }
fn predicates(&self) -> Box<dyn Iterator<Item = Box<dyn PredicateLookup>>> { ... }
fn predicate_additions(
        &self
    ) -> Box<dyn Iterator<Item = Box<dyn LayerPredicateLookup>>> { ... }
fn predicate_removals(
        &self
    ) -> Box<dyn Iterator<Item = Box<dyn LayerPredicateLookup>>> { ... }
fn triple_exists(&self, subject: u64, predicate: u64, object: u64) -> bool { ... }
fn id_triple_exists(&self, triple: IdTriple) -> bool { ... }
fn string_triple_exists(&self, triple: &StringTriple) -> bool { ... }
fn triples(&self) -> Box<dyn Iterator<Item = IdTriple>> { ... }
fn string_triple_to_id(&self, triple: &StringTriple) -> Option<IdTriple> { ... }
fn string_triple_to_partially_resolved(
        &self,
        triple: &StringTriple
    ) -> PartiallyResolvedTriple { ... }
fn id_triple_to_string(&self, triple: &IdTriple) -> Option<StringTriple> { ... }
fn is_ancestor_of(&self, other: &dyn Layer) -> bool { ... } }

A layer containing dictionary entries and triples.

A layer can be queried. To answer queries, layers will check their own data structures, and if they have a parent, the parent is queried as well.

Required methods

fn name(&self) -> [u32; 5]

The name of this layer.

fn parent(&self) -> Option<&dyn Layer>

The parent of this layer, or None if this is a base layer.

fn node_and_value_count(&self) -> usize

The amount of nodes and values known to this layer. This also counts entries in the parent.

fn predicate_count(&self) -> usize

The amount of predicates known to this layer. This also counts entries in the parent.

fn predicate_dict_get(&self, id: usize) -> Option<String>

Predicate dictionary get function

fn predicate_dict_len(&self) -> usize

Predicate dict length of this specific layer

fn predicate_dict_id(&self, predicate: &str) -> Option<u64>

Predicate dict id of current layer

fn node_dict_id(&self, subject: &str) -> Option<u64>

Node dict id of current layer

fn node_dict_get(&self, id: usize) -> Option<String>

Node dictionary get function

fn node_dict_len(&self) -> usize

Node dict length of this specific layer

fn value_dict_id(&self, value: &str) -> Option<u64>

Value dict id of current layer

fn value_dict_len(&self) -> usize

Value dict length of this specific layer

fn value_dict_get(&self, id: usize) -> Option<String>

Value dictionary get function

fn subject_id(&self, subject: &str) -> Option<u64>

The numerical id of a subject, or None if the subject cannot be found.

fn predicate_id(&self, predicate: &str) -> Option<u64>

The numerical id of a predicate, or None if the predicate cannot be found.

fn object_node_id(&self, object: &str) -> Option<u64>

The numerical id of a node object, or None if the node object cannot be found.

fn object_value_id(&self, object: &str) -> Option<u64>

The numerical id of a value object, or None if the value object cannot be found.

fn id_subject(&self, id: u64) -> Option<String>

The subject corresponding to a numerical id, or None if it cannot be found.

fn id_predicate(&self, id: u64) -> Option<String>

The predicate corresponding to a numerical id, or None if it cannot be found.

fn id_object(&self, id: u64) -> Option<ObjectType>

The object corresponding to a numerical id, or None if it cannot be found.

fn subject_additions(
    &self
) -> Box<dyn Iterator<Item = Box<dyn LayerSubjectLookup>>>

Returns an iterator over all triple data added by this layer.

This data is returned by SubjectLookup. Each such object stores a subject id, and knows how to retrieve any linked predicate-object pair.

fn subject_removals(
    &self
) -> Box<dyn Iterator<Item = Box<dyn LayerSubjectLookup>>>

Returns an iterator over all triple data removed by this layer.

This data is returned by SubjectLookup. Each such object stores a subject id, and knows how to retrieve any linked predicate-object pair.

fn lookup_subject_addition(
    &self,
    subject: u64
) -> Option<Box<dyn LayerSubjectLookup>>

Returns a SubjectLookup object for the given subject, or None if it cannot be constructed.

Note that even if a value is returned here, that doesn't necessarily mean that there will be triples for the given subject. All it means is that this layer or a parent layer has registered an addition involving this subject. However, later layers may have then removed every triple involving this subject.

fn lookup_subject_removal(
    &self,
    subject: u64
) -> Option<Box<dyn LayerSubjectLookup>>

Returns a SubjectLookup object for the given subject, or None if it cannot be constructed.

This will only lookup in the current layer.

fn object_additions(
    &self
) -> Box<dyn Iterator<Item = Box<dyn LayerObjectLookup>>>

Returns an iterator over all objects added by this layer.

Objects are returned as an ObjectLookup, an object that can then be queried for subject-predicate pairs pointing to that object.

fn object_removals(
    &self
) -> Box<dyn Iterator<Item = Box<dyn LayerObjectLookup>>>

Returns an iterator over all objects removed by this layer.

Objects are returned as an ObjectLookup, an object that can then be queried for subject-predicate pairs pointing to that object.

fn lookup_object_addition(
    &self,
    object: u64
) -> Option<Box<dyn LayerObjectLookup>>

Returns an ObjectLookup for the given object, or None if it could not be constructed.

This will only lookup in the current layer.

fn lookup_object_removal(
    &self,
    object: u64
) -> Option<Box<dyn LayerObjectLookup>>

Returns an ObjectLookup for the given object, or None if it could not be constructed.

This will only lookup in the current layer.

fn lookup_predicate_addition(
    &self,
    predicate: u64
) -> Option<Box<dyn LayerPredicateLookup>>

Returns a PredicateLookup for the given predicate, or None if it could not be constructed.

This will only lookup in the current layer.

fn lookup_predicate_removal(
    &self,
    predicate: u64
) -> Option<Box<dyn LayerPredicateLookup>>

Returns a PredicateLookup for the given predicate, or None if it could not be constructed.

This will only lookup in the current layer.

fn clone_boxed(&self) -> Box<dyn Layer>

Return a clone of this layer in a box.

Loading content...

Provided methods

fn subjects(&self) -> Box<dyn Iterator<Item = Box<dyn SubjectLookup>>>

Returns an iterator over all triple data known to this layer.

This data is returned by SubjectLookup. Each such object stores a subject id, and knows how to retrieve any linked predicate-object pair.

fn lookup_subject(&self, subject: u64) -> Option<Box<dyn SubjectLookup>>

Returns a SubjectLookup object for the given subject, or None if it cannot be constructed.

Note that even if a value is returned here, that doesn't necessarily mean that there will be triples for the given subject. All it means is that this layer or a parent layer has registered an addition involving this subject. However, later layers may have then removed every triple involving this subject.

fn objects(&self) -> Box<dyn Iterator<Item = Box<dyn ObjectLookup>>>

Returns an iterator over all objects known to this layer.

Objects are returned as an ObjectLookup, an object that can then be queried for subject-predicate pairs pointing to that object.

fn lookup_object(&self, object: u64) -> Option<Box<dyn ObjectLookup>>

Returns an ObjectLookup for the given object, or None if it could not be constructed.

This will only lookup in the current layer. Note that even if a value is returned here, that doesn't necessarily mean that there will be triples for the given object. All it means is that this layer or a parent layer has registered an addition involving this object. However, later layers may have then removed every triple involving this object.

fn lookup_predicate(&self, predicate: u64) -> Option<Box<dyn PredicateLookup>>

Returns a PredicateLookup for the given predicate, or None if it could not be constructed.

Note that even if a value is returned here, that doesn't necessarily mean that there will be triples for the given predicate. All it means is that this layer or a parent layer has registered an addition involving this predicate. However, later layers may have then removed every triple involving this predicate.

fn all_counts(&self) -> LayerCounts

Create a struct with all the counts

fn predicates(&self) -> Box<dyn Iterator<Item = Box<dyn PredicateLookup>>>

fn predicate_additions(
    &self
) -> Box<dyn Iterator<Item = Box<dyn LayerPredicateLookup>>>

fn predicate_removals(
    &self
) -> Box<dyn Iterator<Item = Box<dyn LayerPredicateLookup>>>

fn triple_exists(&self, subject: u64, predicate: u64, object: u64) -> bool

Returns true if the given triple exists, and false otherwise.

fn id_triple_exists(&self, triple: IdTriple) -> bool

Returns true if the given triple exists, and false otherwise.

fn string_triple_exists(&self, triple: &StringTriple) -> bool

Returns true if the given triple exists, and false otherwise.

fn triples(&self) -> Box<dyn Iterator<Item = IdTriple>>

Iterator over all triples known to this layer.

This is a convenient werapper around SubjectLookup and SubjectPredicateLookup style querying.

fn string_triple_to_id(&self, triple: &StringTriple) -> Option<IdTriple>

Convert a StringTriple to an IdTriple, returning None if any of the strings in the triple could not be resolved.

fn string_triple_to_partially_resolved(
    &self,
    triple: &StringTriple
) -> PartiallyResolvedTriple

Convert all known strings in the given string triple to ids.

fn id_triple_to_string(&self, triple: &IdTriple) -> Option<StringTriple>

Convert an id triple to the corresponding string version, returning None if any of those ids could not be converted.

fn is_ancestor_of(&self, other: &dyn Layer) -> bool

Returns true if the given layer is an ancestor of this layer, false otherwise.

Loading content...

Implementors

impl Layer for StoreLayer[src]

impl Layer for SyncStoreLayer[src]

impl<M: 'static + AsRef<[u8]> + Clone + Send + Sync> Layer for BaseLayer<M>[src]

impl<M: 'static + AsRef<[u8]> + Clone + Send + Sync> Layer for ChildLayer<M>[src]

Loading content...