pub struct Schema {
pub entid_map: BTreeMap<i64, Keyword>,
pub ident_map: BTreeMap<Keyword, i64>,
pub attribute_map: BTreeMap<i64, Attribute>,
pub component_attributes: Vec<i64>,
}Expand description
Represents a Mentat schema.
Maintains the mapping between string idents and positive integer entids; and exposes the schema flags associated to a given entid (equivalently, ident).
TODO: consider a single bi-directional map instead of separate ident->entid and entid->ident maps.
Fields§
§entid_map: BTreeMap<i64, Keyword>Map entid->ident.
Invariant: is the inverse map of ident_map.
ident_map: BTreeMap<Keyword, i64>Map ident->entid.
Invariant: is the inverse map of entid_map.
attribute_map: BTreeMap<i64, Attribute>Map entid->attribute flags.
Invariant: key-set is the same as the key-set of entid_map (equivalently, the value-set of
ident_map).
component_attributes: Vec<i64>Maintain a vec of unique attribute IDs for which the corresponding attribute in attribute_map
has .component == true.
Implementations§
Source§impl Schema
impl Schema
pub fn new( ident_map: BTreeMap<Keyword, i64>, entid_map: BTreeMap<i64, Keyword>, attribute_map: BTreeMap<i64, Attribute>, ) -> Schema
Sourcepub fn to_edn_value(&self) -> Value
pub fn to_edn_value(&self) -> Value
Returns an symbolic representation of the schema suitable for applying across Mentat stores.
pub fn update_component_attributes(&mut self)
Trait Implementations§
impl Eq for Schema
Source§impl HasSchema for Schema
impl HasSchema for Schema
Source§fn is_attribute<T>(&self, x: T) -> bool
fn is_attribute<T>(&self, x: T) -> bool
Return true if the provided entid identifies an attribute in this schema.
Source§fn identifies_attribute(&self, x: &Keyword) -> bool
fn identifies_attribute(&self, x: &Keyword) -> bool
Return true if the provided ident identifies an attribute in this schema.
fn entid_for_type(&self, t: ValueType) -> Option<KnownEntid>
fn get_ident<T>(&self, x: T) -> Option<&Keyword>
fn get_entid(&self, x: &Keyword) -> Option<KnownEntid>
fn attribute_for_entid<T>(&self, x: T) -> Option<&Attribute>
fn attribute_for_ident( &self, ident: &Keyword, ) -> Option<(&Attribute, KnownEntid)>
fn component_attributes(&self) -> &[i64]
Source§impl Ord for Schema
impl Ord for Schema
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for Schema
impl PartialOrd for Schema
Source§impl SchemaBuilding for Schema
impl SchemaBuilding for Schema
Source§fn from_ident_map_and_attribute_map(
ident_map: BTreeMap<Keyword, i64>,
attribute_map: BTreeMap<i64, Attribute>,
) -> Result<Schema, DbError>
fn from_ident_map_and_attribute_map( ident_map: BTreeMap<Keyword, i64>, attribute_map: BTreeMap<i64, Attribute>, ) -> Result<Schema, DbError>
Create a valid Schema from the constituent maps.
Source§fn from_ident_map_and_triples<U>(
ident_map: BTreeMap<Keyword, i64>,
assertions: U,
) -> Result<Schema, DbError>
fn from_ident_map_and_triples<U>( ident_map: BTreeMap<Keyword, i64>, assertions: U, ) -> Result<Schema, DbError>
Turn vec![(Keyword(:ident), Keyword(:key), TypedValue(:value)), …] into a Mentat Schema.
fn require_ident(&self, entid: i64) -> Result<&Keyword, DbError>
fn require_entid(&self, ident: &Keyword) -> Result<KnownEntid, DbError>
fn require_attribute_for_entid(&self, entid: i64) -> Result<&Attribute, DbError>
impl StructuralPartialEq for Schema
Auto Trait Implementations§
impl Freeze for Schema
impl RefUnwindSafe for Schema
impl Send for Schema
impl Sync for Schema
impl Unpin for Schema
impl UnsafeUnpin for Schema
impl UnwindSafe for Schema
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.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