Struct bonsaidb_core::schema::Schematic
source · [−]pub struct Schematic {
pub name: SchemaName,
/* private fields */
}Expand description
A collection of defined collections and views.
Fields
name: SchemaNameThe name of the schema this was built from.
Implementations
sourceimpl Schematic
impl Schematic
sourcepub fn from_schema<S: Schema + ?Sized>() -> Result<Self, Error>
pub fn from_schema<S: Schema + ?Sized>() -> Result<Self, Error>
Returns an initialized version from S.
sourcepub fn define_collection<C: Collection + 'static>(
&mut self
) -> Result<(), Error>
pub fn define_collection<C: Collection + 'static>(
&mut self
) -> Result<(), Error>
Adds the collection C and its views.
sourcepub fn define_view<V: ViewSchema<View = V> + SerializedView + Clone + 'static>(
&mut self,
view: V
) -> Result<(), Error>
pub fn define_view<V: ViewSchema<View = V> + SerializedView + Clone + 'static>(
&mut self,
view: V
) -> Result<(), Error>
Adds the view V.
sourcepub fn define_view_with_schema<V: SerializedView + 'static, S: ViewSchema<View = V> + 'static>(
&mut self,
view: V,
schema: S
) -> Result<(), Error>
pub fn define_view_with_schema<V: SerializedView + 'static, S: ViewSchema<View = V> + 'static>(
&mut self,
view: V,
schema: S
) -> Result<(), Error>
Adds the view V.
sourcepub fn contains<C: Collection + 'static>(&self) -> bool
pub fn contains<C: Collection + 'static>(&self) -> bool
Returns true if this schema contains the collection C.
sourcepub fn contains_collection_id(&self, collection: &CollectionName) -> bool
pub fn contains_collection_id(&self, collection: &CollectionName) -> bool
Returns true if this schema contains the collection C.
sourcepub fn view_by_name(&self, name: &ViewName) -> Option<&dyn Serialized>
pub fn view_by_name(&self, name: &ViewName) -> Option<&dyn Serialized>
Looks up a view::Serialized by name.
sourcepub fn view<V: View + 'static>(&self) -> Option<&dyn Serialized>
pub fn view<V: View + 'static>(&self) -> Option<&dyn Serialized>
Looks up a view::Serialized through the the type V.
sourcepub fn views(&self) -> impl Iterator<Item = &dyn Serialized>
pub fn views(&self) -> impl Iterator<Item = &dyn Serialized>
Iterates over all registered views.
sourcepub fn views_in_collection(
&self,
collection: &CollectionName
) -> Option<Vec<&dyn Serialized>>
pub fn views_in_collection(
&self,
collection: &CollectionName
) -> Option<Vec<&dyn Serialized>>
Iterates over all views that belong to collection.
sourcepub fn unique_views_in_collection(
&self,
collection: &CollectionName
) -> Option<Vec<&dyn Serialized>>
pub fn unique_views_in_collection(
&self,
collection: &CollectionName
) -> Option<Vec<&dyn Serialized>>
Iterates over all views that are unique that belong to collection.
sourcepub fn encryption_key_for_collection(
&self,
collection: &CollectionName
) -> Option<&KeyId>
pub fn encryption_key_for_collection(
&self,
collection: &CollectionName
) -> Option<&KeyId>
Returns a collection’s default encryption key, if one was defined.
sourcepub fn collections(&self) -> Vec<CollectionName>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
pub fn collections(&self) -> Vec<CollectionName>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
Returns a list of all collections contained in this schematic.
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Schematic
impl Send for Schematic
impl Sync for Schematic
impl Unpin for Schematic
impl !UnwindSafe for Schematic
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more