Database

Struct Database 

Source
pub struct Database {
    pub name: String,
    pub schema: SchemaName,
}
Expand description

A database stored in BonsaiDb.

Fields§

§name: String

The name of the database.

§schema: SchemaName

The schema defining the database.

Trait Implementations§

Source§

impl Clone for Database

Source§

fn clone(&self) -> Database

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Collection for Database

Source§

type PrimaryKey = u64

The unique id type. Each document stored in a collection will be uniquely identified by this type. Read more
Source§

fn collection_name() -> CollectionName

The unique name of this collection. Each collection must be uniquely named within the Schema it is registered within.
Source§

fn define_views(schema: &mut Schematic) -> Result<(), Error>

Defines all Views in this collection in schema.
Source§

fn encryption_key() -> Option<KeyId>

If a KeyId is returned, this collection will be stored encrypted at-rest using the key specified.
Source§

impl Debug for Database

Source§

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

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

impl DefaultSerialization for Database

Source§

fn natural_id(&self) -> Option<Self::PrimaryKey>

Returns the natural identifier of contents. This is called when pushing values into a collection, before attempting to automatically assign a unique id.
Source§

impl<'de> Deserialize<'de> for Database

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<Database, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl NamedCollection for Database

Source§

type ByNameView = ByName

The name view defined for the collection.
Source§

fn load<'name, N, C>( id: N, connection: &C, ) -> Result<Option<CollectionDocument<Self>>, Error>
where N: Nameable<'name, Self::PrimaryKey> + Send + Sync, C: Connection, Self: Sized + SerializedCollection + 'static,

Gets a CollectionDocument with id from connection.
Source§

fn load_async<'name, 'life0, 'async_trait, N, C>( id: N, connection: &'life0 C, ) -> Pin<Box<dyn Future<Output = Result<Option<CollectionDocument<Self>>, Error>> + Send + 'async_trait>>
where 'name: 'async_trait, 'life0: 'async_trait, Self: Sized + SerializedCollection + 'static + Send + 'async_trait, N: 'async_trait + Nameable<'name, Self::PrimaryKey> + Send + Sync, C: 'async_trait + AsyncConnection,

Gets a CollectionDocument with id from connection.
Source§

fn entry<'connection, 'name, N, C>( id: N, connection: &'connection C, ) -> Entry<'connection, 'name, C, Self, (), ()>
where N: Into<NamedReference<'name, Self::PrimaryKey>> + Send + Sync, C: Connection, Self: Sized + SerializedCollection,

Gets a CollectionDocument with id from connection.
Source§

fn entry_async<'connection, 'name, N, C>( id: N, connection: &'connection C, ) -> AsyncEntry<'connection, 'name, C, Self, (), ()>

Gets a CollectionDocument with id from connection.
Source§

fn load_document<'name, N, C>( name: N, connection: &C, ) -> Result<Option<OwnedDocument>, Error>
where N: Nameable<'name, Self::PrimaryKey> + Send + Sync, C: Connection, Self: Sized + SerializedCollection,

Loads a document from this collection by name, if applicable. Return Ok(None) if unsupported.
Source§

fn load_document_async<'name, 'life0, 'async_trait, N, C>( name: N, connection: &'life0 C, ) -> Pin<Box<dyn Future<Output = Result<Option<OwnedDocument>, Error>> + Send + 'async_trait>>
where 'name: 'async_trait, 'life0: 'async_trait, Self: Sized + SerializedCollection + Send + 'async_trait, N: 'async_trait + Nameable<'name, Self::PrimaryKey> + Send + Sync, C: 'async_trait + AsyncConnection,

Loads a document from this collection by name, if applicable. Return Ok(None) if unsupported.
Source§

fn delete_by_name<C>(name: &str, connection: &C) -> Result<bool, Error>

Deletes a document by its name. Returns true if a document was deleted.
Source§

fn delete_by_name_async<'life0, 'life1, 'async_trait, C>( name: &'life0 str, connection: &'life1 C, ) -> Pin<Box<dyn Future<Output = Result<bool, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: Sized + SerializedCollection + Send + 'async_trait, C: 'async_trait + AsyncConnection,

Deletes a document by its name. Returns true if a document was deleted.
Source§

impl PartialEq for Database

Source§

fn eq(&self, other: &Database) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Database

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for Database

Source§

impl StructuralPartialEq for Database

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<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Schema for T
where T: Collection + 'static,

Source§

fn schema_name() -> SchemaName

Returns the unique SchemaName for this schema.
Source§

fn define_collections(schema: &mut Schematic) -> Result<(), Error>

Defines the Collections into schema.
Source§

fn schematic() -> Result<Schematic, Error>

Retrieves the Schematic for this schema.
Source§

impl<T> SerializedCollection for T

Source§

type Contents = T

The type of the contents stored in documents in this collection.
Source§

type Format = Pot

The serialization format for this collection.
Source§

fn format() -> <T as SerializedCollection>::Format

Returns the configured instance of Self::Format.
Source§

fn natural_id( contents: &<T as SerializedCollection>::Contents, ) -> Option<<T as Collection>::PrimaryKey>

Returns the natural identifier of contents. This is called when pushing values into a collection, before attempting to automatically assign a unique id.
Source§

fn deserialize(data: &[u8]) -> Result<Self::Contents, Error>

Deserialize data as Self::Contents using this collection’s format.
Source§

fn document_contents<D>(doc: &D) -> Result<Self::Contents, Error>
where D: Document<Self>, Self: Sized,

Returns the deserialized contents of doc.
Source§

fn set_document_contents<D>( doc: &mut D, contents: Self::Contents, ) -> Result<(), Error>
where D: Document<Self>, Self: Sized,

Sets the contents of doc to contents.
Source§

fn serialize(item: &Self::Contents) -> Result<Vec<u8>, Error>

Serialize item using this collection’s format.
Source§

fn get<C, PrimaryKey>( id: &PrimaryKey, connection: &C, ) -> Result<Option<CollectionDocument<Self>>, Error>
where C: Connection, PrimaryKey: KeyEncoding<Self::PrimaryKey>, Self: Sized,

Gets a CollectionDocument with id from connection. Read more
Source§

fn get_async<'life0, 'life1, 'async_trait, C, PrimaryKey>( id: &'life0 PrimaryKey, connection: &'life1 C, ) -> Pin<Box<dyn Future<Output = Result<Option<CollectionDocument<Self>>, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, C: AsyncConnection + 'async_trait, PrimaryKey: KeyEncoding<Self::PrimaryKey> + 'async_trait, Self: Sized + Send + 'async_trait,

Gets a CollectionDocument with id from connection. Read more
Source§

fn get_multiple<'id, C, DocumentIds, PrimaryKey, I>( ids: DocumentIds, connection: &C, ) -> Result<Vec<CollectionDocument<Self>>, Error>
where C: Connection, DocumentIds: IntoIterator<Item = &'id PrimaryKey, IntoIter = I> + Send + Sync, I: Iterator<Item = &'id PrimaryKey> + Send + Sync, PrimaryKey: KeyEncoding<Self::PrimaryKey> + 'id, Self: Sized,

Retrieves all documents matching ids. Documents that are not found are not returned, but no error will be generated. Read more
Source§

fn get_multiple_async<'id, 'life0, 'async_trait, C, DocumentIds, PrimaryKey, I>( ids: DocumentIds, connection: &'life0 C, ) -> Pin<Box<dyn Future<Output = Result<Vec<CollectionDocument<Self>>, Error>> + Send + 'async_trait>>
where 'id: 'async_trait, 'life0: 'async_trait, C: AsyncConnection + 'async_trait, DocumentIds: IntoIterator<Item = &'id PrimaryKey, IntoIter = I> + Send + Sync + 'async_trait, I: Iterator<Item = &'id PrimaryKey> + Send + Sync + 'async_trait, PrimaryKey: KeyEncoding<Self::PrimaryKey> + 'id + 'async_trait, Self: Sized + Send + 'async_trait,

Retrieves all documents matching ids. Documents that are not found are not returned, but no error will be generated. Read more
Source§

fn list<'id, R, PrimaryKey, C>( ids: R, connection: &'id C, ) -> List<'id, C, Self, PrimaryKey>
where R: Into<RangeRef<'id, Self::PrimaryKey, PrimaryKey>>, C: Connection, PrimaryKey: KeyEncoding<Self::PrimaryKey> + PartialEq + 'id, Self::PrimaryKey: Borrow<PrimaryKey> + PartialEq<PrimaryKey>, Self: Sized,

Retrieves all documents matching the range of ids. Read more
Source§

fn list_async<'id, R, PrimaryKey, C>( ids: R, connection: &'id C, ) -> AsyncList<'id, C, Self, PrimaryKey>
where R: Into<RangeRef<'id, Self::PrimaryKey, PrimaryKey>>, C: AsyncConnection, PrimaryKey: KeyEncoding<Self::PrimaryKey> + PartialEq + 'id + ?Sized, Self::PrimaryKey: Borrow<PrimaryKey> + PartialEq<PrimaryKey>, Self: Sized,

Retrieves all documents matching the range of ids. Read more
Source§

fn list_with_prefix<'a, PrimaryKey, C>( prefix: &'a PrimaryKey, connection: &'a C, ) -> List<'a, C, Self, PrimaryKey>
where C: Connection, Self: Sized, PrimaryKey: IntoPrefixRange<'a, Self::PrimaryKey> + KeyEncoding<Self::PrimaryKey> + PartialEq + ?Sized, Self::PrimaryKey: Borrow<PrimaryKey> + PartialEq<PrimaryKey>,

Retrieves all documents with ids that start with prefix. Read more
Source§

fn list_with_prefix_async<'a, PrimaryKey, C>( prefix: &'a PrimaryKey, connection: &'a C, ) -> AsyncList<'a, C, Self, PrimaryKey>
where C: AsyncConnection, Self: Sized, PrimaryKey: IntoPrefixRange<'a, Self::PrimaryKey> + KeyEncoding<Self::PrimaryKey> + PartialEq + ?Sized, Self::PrimaryKey: Borrow<PrimaryKey> + PartialEq<PrimaryKey>,

Retrieves all documents with ids that start with prefix. Read more
Source§

fn all<C>(connection: &C) -> List<'_, C, Self, Self::PrimaryKey>
where C: Connection, Self: Sized,

Retrieves all documents. Read more
Source§

fn all_async<C>(connection: &C) -> AsyncList<'_, C, Self, Self::PrimaryKey>
where C: AsyncConnection, Self: Sized,

Retrieves all documents. Read more
Source§

fn push<Cn>( contents: Self::Contents, connection: &Cn, ) -> Result<CollectionDocument<Self>, InsertError<Self::Contents>>
where Cn: Connection, Self: Sized + 'static,

Pushes this value into the collection, returning the created document. This function is useful when Self != Self::Contents. Read more
Source§

fn push_async<'life0, 'async_trait, Cn>( contents: Self::Contents, connection: &'life0 Cn, ) -> Pin<Box<dyn Future<Output = Result<CollectionDocument<Self>, InsertError<Self::Contents>>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: Sized + 'static + Send + 'async_trait, Self::Contents: 'async_trait, Cn: 'async_trait + AsyncConnection,

Pushes this value into the collection, returning the created document. This function is useful when Self != Self::Contents. Read more
Source§

fn push_all<Contents, Cn>( contents: Contents, connection: &Cn, ) -> Result<Vec<CollectionDocument<Self>>, Error>
where Contents: IntoIterator<Item = Self::Contents>, Cn: Connection, Self: Sized + 'static, Self::PrimaryKey: Default,

Pushes all contents in a single transaction. If successful, all collection documents will be returned. If an error occurs during this operation, no documents will be pushed. Read more
Source§

fn push_all_async<'life0, 'async_trait, Contents, Cn>( contents: Contents, connection: &'life0 Cn, ) -> Pin<Box<dyn Future<Output = Result<Vec<CollectionDocument<Self>>, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: Sized + 'static + Send + 'async_trait, Self::PrimaryKey: Default, <Contents as IntoIterator>::IntoIter: Send, Contents: 'async_trait + IntoIterator<Item = Self::Contents> + Send, Cn: 'async_trait + AsyncConnection,

Pushes all contents in a single transaction. If successful, all collection documents will be returned. If an error occurs during this operation, no documents will be pushed. Read more
Source§

fn push_into<Cn>( self, connection: &Cn, ) -> Result<CollectionDocument<Self>, InsertError<Self>>
where Cn: Connection, Self: Sized + SerializedCollection<Contents = Self> + 'static,

Pushes this value into the collection, returning the created document. Read more
Source§

fn push_into_async<'life0, 'async_trait, Cn>( self, connection: &'life0 Cn, ) -> Pin<Box<dyn Future<Output = Result<CollectionDocument<Self>, InsertError<Self>>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: Sized + SerializedCollection<Contents = Self> + 'static + Send + 'async_trait, Cn: 'async_trait + AsyncConnection,

Pushes this value into the collection, returning the created document. Read more
Source§

fn push_in_transaction( &self, transaction: &mut Transaction, ) -> Result<(), Error>
where Self: Sized + SerializedCollection<Contents = Self> + 'static,

Pushes an insert Operation without a key to the transaction for this document, allowing the database to generate the primary key for the document. Read more
Source§

fn insert<PrimaryKey, Cn>( id: &PrimaryKey, contents: Self::Contents, connection: &Cn, ) -> Result<CollectionDocument<Self>, InsertError<Self::Contents>>
where PrimaryKey: KeyEncoding<Self::PrimaryKey>, Cn: Connection, Self: Sized + 'static,

Inserts this value into the collection with the specified id, returning the created document. Read more
Source§

fn insert_async<'life0, 'life1, 'async_trait, PrimaryKey, Cn>( id: &'life0 PrimaryKey, contents: Self::Contents, connection: &'life1 Cn, ) -> Pin<Box<dyn Future<Output = Result<CollectionDocument<Self>, InsertError<Self::Contents>>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, PrimaryKey: KeyEncoding<Self::PrimaryKey> + 'async_trait, Cn: AsyncConnection + 'async_trait, Self: Sized + 'static + Send + 'async_trait, Self::Contents: 'async_trait,

Inserts this value into the collection with the specified id, returning the created document. Read more
Source§

fn insert_into<PrimaryKey, Cn>( self, id: &PrimaryKey, connection: &Cn, ) -> Result<CollectionDocument<Self>, InsertError<Self>>
where PrimaryKey: KeyEncoding<Self::PrimaryKey>, Cn: Connection, Self: Sized + SerializedCollection<Contents = Self> + 'static,

Inserts this value into the collection with the given id, returning the created document. Read more
Source§

fn insert_into_async<'life0, 'life1, 'async_trait, PrimaryKey, Cn>( self, id: &'life0 PrimaryKey, connection: &'life1 Cn, ) -> Pin<Box<dyn Future<Output = Result<CollectionDocument<Self>, InsertError<Self>>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, PrimaryKey: KeyEncoding<Self::PrimaryKey> + 'async_trait, Cn: AsyncConnection + 'async_trait, Self: Sized + SerializedCollection<Contents = Self> + 'static + Send + 'async_trait,

Inserts this value into the collection with the given id, returning the created document. Read more
Source§

fn insert_in_transaction( &self, key: &Self::PrimaryKey, transaction: &mut Transaction, ) -> Result<(), Error>
where Self: Sized + SerializedCollection<Contents = Self> + 'static,

Pushes an insert Operation to the transaction for this document. Read more
Source§

fn overwrite<PrimaryKey, Cn>( id: &PrimaryKey, contents: Self::Contents, connection: &Cn, ) -> Result<CollectionDocument<Self>, InsertError<Self::Contents>>
where PrimaryKey: KeyEncoding<Self::PrimaryKey>, Cn: Connection, Self: Sized + 'static,

Overwrites this value into the collection with the specified id, returning the created or updated document. Read more
Source§

fn overwrite_async<'life0, 'life1, 'async_trait, PrimaryKey, Cn>( id: &'life0 PrimaryKey, contents: Self::Contents, connection: &'life1 Cn, ) -> Pin<Box<dyn Future<Output = Result<CollectionDocument<Self>, InsertError<Self::Contents>>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, PrimaryKey: KeyEncoding<Self::PrimaryKey> + 'async_trait, Cn: AsyncConnection + 'async_trait, Self: Sized + 'static + Send + 'async_trait, Self::Contents: 'async_trait,

Overwrites this value into the collection with the specified id, returning the created or updated document. Read more
Source§

fn overwrite_into<Cn, PrimaryKey>( self, id: &PrimaryKey, connection: &Cn, ) -> Result<CollectionDocument<Self>, InsertError<Self>>
where Cn: Connection, PrimaryKey: KeyEncoding<Self::PrimaryKey>, Self: Sized + SerializedCollection<Contents = Self> + 'static,

Overwrites this value into the collection with the given id, returning the created or updated document. Read more
Source§

fn overwrite_in_transaction<PrimaryKey>( &self, id: &PrimaryKey, transaction: &mut Transaction, ) -> Result<(), Error>
where PrimaryKey: KeyEncoding<Self::PrimaryKey>, Self: Sized + SerializedCollection<Contents = Self> + 'static,

Pushes an overwrite Operation to the transaction for this document. Read more
Source§

fn overwrite_into_async<'life0, 'life1, 'async_trait, Cn, PrimaryKey>( self, id: &'life0 PrimaryKey, connection: &'life1 Cn, ) -> Pin<Box<dyn Future<Output = Result<CollectionDocument<Self>, InsertError<Self>>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, PrimaryKey: KeyEncoding<Self::PrimaryKey> + 'async_trait, Self: Sized + SerializedCollection<Contents = Self> + 'static + Send + 'async_trait, Cn: 'async_trait + AsyncConnection,

Overwrites this value into the collection with the given id, returning the created or updated document. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> ErasedDestructor for T
where T: 'static,