Schematic

Struct Schematic 

Source
pub struct Schematic {
    pub name: SchemaName,
    /* private fields */
}
Expand description

A collection of defined collections and views.

Fields§

§name: SchemaName

The name of the schema this was built from.

Implementations§

Source§

impl Schematic

Source

pub fn from_schema<S: Schema + ?Sized>() -> Result<Self, Error>

Returns an initialized version from S.

Source

pub fn define_collection<C: Collection + 'static>( &mut self, ) -> Result<(), Error>

Adds the collection C and its views.

Source

pub fn define_view<V: MapReduce + ViewSchema<View = V> + SerializedView + Clone + 'static>( &mut self, view: V, ) -> Result<(), Error>

Adds the view V.

Source

pub fn define_view_with_schema<V: SerializedView + 'static, S: MapReduce + ViewSchema<View = V> + 'static>( &mut self, view: V, schema: S, ) -> Result<(), Error>

Adds the view V.

Source

pub fn contains_collection<C: Collection + 'static>(&self) -> bool

Returns true if this schema contains the collection C.

Source

pub fn collection_primary_key_description<'a>( &'a self, collection: &CollectionName, ) -> Option<&'a KeyDescription>

Returns the description of the primary keyof the collection with the given name, or None if the collection can’t be found.

Source

pub fn next_id_for_collection( &self, collection: &CollectionName, id: Option<DocumentId>, ) -> Result<DocumentId, Error>

Returns the next id in sequence for the collection, if the primary key type supports the operation and the next id would not overflow.

Source

pub fn view_by_name(&self, name: &ViewName) -> Result<&dyn Serialized, Error>

Looks up a view::Serialized by name.

Source

pub fn view<V: View + 'static>(&self) -> Result<&dyn Serialized, Error>

Looks up a view::Serialized through the the type V.

Source

pub fn views(&self) -> impl Iterator<Item = &dyn Serialized>

Iterates over all registered views.

Source

pub fn views_in_collection( &self, collection: &CollectionName, ) -> impl Iterator<Item = &dyn Serialized>

Iterates over all views that belong to collection.

Source

pub fn eager_views_in_collection( &self, collection: &CollectionName, ) -> impl Iterator<Item = &dyn Serialized>

Iterates over all views that are eagerly updated that belong to collection.

Source

pub fn encryption_key_for_collection( &self, collection: &CollectionName, ) -> Option<&KeyId>

Returns a collection’s default encryption key, if one was defined.

Source

pub fn collections(&self) -> impl Iterator<Item = &CollectionName>

Returns a list of all collections contained in this schematic.

Trait Implementations§

Source§

impl Debug for Schematic

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> From<&'a Schematic> for SchemaSummary

Source§

fn from(schematic: &'a Schematic) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.