Skip to content

Commit

Permalink
Adding connection::Collection "prelude" docs
Browse files Browse the repository at this point in the history
  • Loading branch information
ecton committed Feb 5, 2022
1 parent 2b3ae5c commit e434d04
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
29 changes: 29 additions & 0 deletions crates/bonsaidb-core/src/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,35 @@ pub trait Connection: Send + Sync {
}

/// Interacts with a collection over a `Connection`.
///
/// These examples in this type use this basic collection definition:
///
/// ```rust
/// use bonsaidb_core::{
/// schema::{Collection, CollectionName, DefaultSerialization, Schematic},
/// Error,
/// };
/// use serde::{Deserialize, Serialize};
///
/// #[derive(Debug, Serialize, Deserialize, Default)]
/// pub struct MyCollection {
/// pub rank: u32,
/// pub score: f32,
/// }
///
/// impl Collection for MyCollection {
/// fn collection_name() -> CollectionName {
/// CollectionName::private("MyCollection")
/// }
///
/// fn define_views(schema: &mut Schematic) -> Result<(), Error> {
/// // ...
/// Ok(())
/// }
/// }
///
/// impl DefaultSerialization for MyCollection {}
/// ```
pub struct Collection<'a, Cn, Cl> {
connection: &'a Cn,
_phantom: PhantomData<Cl>, /* allows for extension traits to be written for collections of specific types */
Expand Down
2 changes: 1 addition & 1 deletion crates/bonsaidb-core/src/document/collection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use arc_bytes::serde::{Bytes, CowBytes};

use crate::{
connection::Connection,
document::{BorrowedDocument, Document, Header, OwnedDocument},
document::{BorrowedDocument, Header, OwnedDocument},
schema::SerializedCollection,
Error,
};
Expand Down
2 changes: 1 addition & 1 deletion crates/bonsaidb-core/src/schema/collection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub trait Collection: Debug + Send + Sync {

/// A collection that knows how to serialize and deserialize documents to an associated type.
///
/// These examples in this type use this basic collection definition:
/// These examples for this type use this basic collection definition:
///
/// ```rust
/// use bonsaidb_core::{
Expand Down

0 comments on commit e434d04

Please sign in to comment.