Skip to content
This repository was archived by the owner on Oct 18, 2021. It is now read-only.

Commit c366356

Browse files
committed
Merge pull request #115 from kyeah/documentation
Organized documentation and added module-level documentation
2 parents 1503946 + 2e90b91 commit c366356

27 files changed

+369
-222
lines changed

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ version = "0.1.0"
44
authors = ["Valeri Karpov <[email protected]>",
55
"Saghm Rossi <[email protected]>",
66
"Kevin Yeh <[email protected]>"]
7+
78
description = "An experimental MongoDB driver written by MongoDB interns."
89
repository = "https://github.com/mongodbinc-interns/mongo-rust-driver-prototype"
10+
documentation = "https://mongodbinc-interns.github.io/mongo-rust-driver-prototype/mongodb"
911
readme = "README.md"
1012
keywords = ["mongo", "mongodb", "database", "bson", "nosql"]
1113
license = "apache"

src/apm/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
//! Command Monitoring
2+
//!
3+
//! The APM module provides an intuitive interface for monitoring and responding to runtime information
4+
//! about commands being executed on the server. All non-suppressed commands trigger start and completion
5+
//! hooks defined on the client. Each non-suppressed command is also logged, if a log file was specified
6+
//! during instantiation of the client.
17
pub mod client;
28
mod event;
39
mod listener;

src/auth.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//! Authentication schemes.
12
use bson::Bson::{self, Binary};
23
use bson::Document;
34
use bson::spec::BinarySubtype::Generic;
@@ -19,6 +20,7 @@ const B64_CONFIG : base64::Config = base64::Config { char_set: base64::Character
1920
newline: base64::Newline::LF,
2021
pad: true, line_length: None };
2122

23+
/// Handles SCRAM-SHA-1 authentication logic.
2224
pub struct Authenticator {
2325
db: Database,
2426
}
@@ -37,10 +39,12 @@ struct AuthData {
3739
}
3840

3941
impl Authenticator {
42+
/// Creates a new authenticator.
4043
pub fn new(db: Database) -> Authenticator {
4144
Authenticator { db: db }
4245
}
4346

47+
/// Authenticates a user-password pair against a database.
4448
pub fn auth(self, user: &str, password: &str) -> Result<()> {
4549
let initial_data = try!(self.start(user));
4650
let conversation_id = initial_data.conversation_id.clone();

src/coll/batch.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//! Models for collection-level batch operations.
12
use super::options::WriteModel;
23

34
use bson::Document;

src/coll/error.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//! Write errors for collection-level operations.
12
use bson::{self, Bson};
23
use super::options::WriteModel;
34
use common::WriteConcern;

src/coll/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//! Interface for collection-level operations.
12
mod batch;
23
pub mod error;
34
pub mod options;
@@ -25,7 +26,9 @@ use std::iter::FromIterator;
2526

2627
/// Interfaces with a MongoDB collection.
2728
pub struct Collection {
29+
/// A reference to the database that spawned this collection.
2830
pub db: Database,
31+
/// The namespace of this collection, formatted as db_name.coll_name.
2932
pub namespace: String,
3033
read_preference: ReadPreference,
3134
write_concern: WriteConcern,

src/coll/options.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//! Options for collection-level operations.
12
use bson::{self, Bson};
23
use cursor;
34
use common::{ReadPreference, WriteConcern};
@@ -115,6 +116,7 @@ pub struct FindOneAndUpdateOptions {
115116
}
116117

117118
/// Options for index operations.
119+
#[derive(Clone)]
118120
pub struct IndexOptions {
119121
pub background: Option<bool>,
120122
pub expire_after_seconds: Option<i32>,
@@ -139,17 +141,20 @@ pub struct IndexOptions {
139141
}
140142

141143
/// A single index model.
144+
#[derive(Clone)]
142145
pub struct IndexModel {
143146
pub keys: bson::Document,
144147
pub options: IndexOptions,
145148
}
146149

150+
/// Options for insertMany operations.
147151
#[derive(Clone)]
148152
pub struct InsertManyOptions {
149153
pub ordered: bool,
150154
pub write_concern: Option<WriteConcern>,
151155
}
152156

157+
/// Options for update operations.
153158
#[derive(Clone)]
154159
pub struct UpdateOptions {
155160
pub upsert: bool,

src/coll/results.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//! Results for collection-level operations.
12
use bson;
23
use bson::Bson;
34
use std::collections::BTreeMap;

src/command_type.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
//! Monitorable command types.
2+
3+
/// Executable command types that can be monitored by the driver.
14
#[derive(PartialEq, Eq, Clone)]
25
pub enum CommandType {
36
Aggregate,

src/common.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//! Library-wide utilities.
12
use Error::{self, ArgumentError};
23
use Result;
34

@@ -16,7 +17,7 @@ pub enum ReadMode {
1617
Nearest,
1718
}
1819

19-
impl FromStr for ReadMode {
20+
impl FromStr for ReadMode {
2021
type Err = Error;
2122
fn from_str(s: &str) -> Result<Self> {
2223
Ok(match s {
@@ -63,10 +64,14 @@ impl ReadPreference {
6364

6465
#[derive(Debug, Clone, PartialEq, Eq)]
6566
pub struct WriteConcern {
66-
pub w: i32, // Write replication
67-
pub w_timeout: i32, // Used in conjunction with 'w'. Propagation timeout in ms.
68-
pub j: bool, // If true, will block until write operations have been committed to journal.
69-
pub fsync: bool, // If true and server is not journaling, blocks until server has synced all data files to disk.
67+
/// Write replication
68+
pub w: i32,
69+
/// Used in conjunction with 'w'. Propagation timeout in ms.
70+
pub w_timeout: i32,
71+
/// If true, will block until write operations have been committed to journal.
72+
pub j: bool,
73+
/// If true and server is not journaling, blocks until server has synced all data files to disk.
74+
pub fsync: bool,
7075
}
7176

7277
impl WriteConcern {

0 commit comments

Comments
 (0)