Skip to content

Commit 952a163

Browse files
committed
actually fix rustdoc
1 parent 4a945c8 commit 952a163

File tree

11 files changed

+28
-28
lines changed

11 files changed

+28
-28
lines changed

src/binary/vector.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ const PACKED_BIT: u8 = 0x10;
3030
/// }
3131
///
3232
/// let data = Data { vector: Vector::Int8(vec![0, 1, 2]) };
33-
/// let document = bson::to_document(&data).unwrap();
33+
/// let document = bson::serialize_to_document(&data).unwrap();
3434
/// assert_eq!(document.get("vector").unwrap().element_type(), ElementType::Binary);
3535
///
36-
/// let data: Data = bson::from_document(document).unwrap();
36+
/// let data: Data = bson::deserialize_from_document(document).unwrap();
3737
/// assert_eq!(data.vector, Vector::Int8(vec![0, 1, 2]));
3838
/// ```
3939
///

src/datetime.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ use serde::{Deserialize, Deserializer, Serialize};
7373
///
7474
/// # fn main() -> bson::ser::Result<()> {
7575
/// let f = Foo { date_time: bson::DateTime::now(), chrono_datetime: chrono::Utc::now() };
76-
/// println!("{:?}", bson::to_document(&f)?);
76+
/// println!("{:?}", bson::serialize_to_document(&f)?);
7777
/// # Ok(())
7878
/// # }
7979
/// ```
@@ -170,7 +170,7 @@ use serde::{Deserialize, Deserializer, Serialize};
170170
/// "as_bson": bson::DateTime::from_chrono(dt),
171171
/// };
172172
///
173-
/// assert_eq!(bson::to_document(&foo)?, expected);
173+
/// assert_eq!(bson::serialize_to_document(&foo)?, expected);
174174
/// # }
175175
/// # Ok::<(), Box<dyn std::error::Error>>(())
176176
/// ```

src/document.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -690,7 +690,7 @@ impl Document {
690690
///
691691
/// let mut v: Vec<u8> = Vec::new();
692692
/// let doc = doc! { "x" : 1 };
693-
/// doc.to_writer(&mut v)?;
693+
/// doc.encode_to_writer(&mut v)?;
694694
/// # Ok(())
695695
/// # }
696696
/// ```
@@ -714,14 +714,14 @@ impl Document {
714714
///
715715
/// let mut v: Vec<u8> = Vec::new();
716716
/// let doc = doc! { "x" : 1 };
717-
/// doc.to_writer(&mut v)?;
717+
/// doc.encode_to_writer(&mut v)?;
718718
///
719719
/// // read from mutable reference
720720
/// let mut reader = Cursor::new(v.clone());
721-
/// let doc1 = Document::from_reader(&mut reader)?;
721+
/// let doc1 = Document::decode_from_reader(&mut reader)?;
722722
///
723723
/// // read from owned value
724-
/// let doc2 = Document::from_reader(Cursor::new(v))?;
724+
/// let doc2 = Document::decode_from_reader(Cursor::new(v))?;
725725
///
726726
/// assert_eq!(doc, doc1);
727727
/// assert_eq!(doc, doc2);

src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@
132132
//! use std::io::Read;
133133
//!
134134
//! let mut bytes = hex::decode("0C0000001069000100000000").unwrap();
135-
//! let doc = Document::from_reader(&mut bytes.as_slice()).unwrap(); // { "i": 1 }
135+
//! let doc = Document::decode_from_reader(&mut bytes.as_slice()).unwrap(); // { "i": 1 }
136136
//!
137137
//! let doc = doc! {
138138
//! "hello": "world",
@@ -200,14 +200,14 @@
200200
//! // Deserialize the Person struct from the BSON data, automatically
201201
//! // verifying that the necessary keys are present and that they are of
202202
//! // the correct types.
203-
//! let mut person: Person = bson::from_bson(bson_data).unwrap();
203+
//! let mut person: Person = bson::deserialize_from_bson(bson_data).unwrap();
204204
//!
205205
//! // Do things just like with any other Rust data structure.
206206
//! println!("Redacting {}'s record.", person.name);
207207
//! person.name = "REDACTED".to_string();
208208
//!
209209
//! // Get a serialized version of the input data as a [`Bson`].
210-
//! let redacted_bson = bson::to_bson(&person).unwrap();
210+
//! let redacted_bson = bson::serialize_to_bson(&person).unwrap();
211211
//! ```
212212
//!
213213
//! Any types that implement [`Serialize`](serde::Serialize) and [`Deserialize`](serde::Deserialize)

src/oid.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ impl error::Error for Error {}
9292
///
9393
/// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
9494
/// let f = Foo { oid: ObjectId::new() };
95-
/// println!("bson: {}", bson::to_document(&f)?);
95+
/// println!("bson: {}", bson::serialize_to_document(&f)?);
9696
/// println!("json: {}", serde_json::to_string(&f)?);
9797
/// # Ok(())
9898
/// # }
@@ -127,7 +127,7 @@ impl error::Error for Error {}
127127
/// }
128128
/// # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
129129
/// let f = Foo { oid: ObjectId::new(), oid_as_hex: ObjectId::new() };
130-
/// println!("bson: {}", bson::to_document(&f)?);
130+
/// println!("bson: {}", bson::serialize_to_document(&f)?);
131131
/// println!("json: {}", serde_json::to_string(&f)?);
132132
/// # Ok(())
133133
/// # }

src/raw.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
//! };
2424
//!
2525
//! // See http://bsonspec.org/spec.html for details on the binary encoding of BSON.
26-
//! let doc = RawDocumentBuf::from_bytes(b"\x13\x00\x00\x00\x02hi\x00\x06\x00\x00\x00y'all\x00\x00".to_vec())?;
26+
//! let doc = RawDocumentBuf::decode_from_bytes(b"\x13\x00\x00\x00\x02hi\x00\x06\x00\x00\x00y'all\x00\x00".to_vec())?;
2727
//! let elem = doc.get("hi")?.unwrap();
2828
//!
2929
//! assert_eq!(
@@ -76,7 +76,7 @@
7676
//! use bson::raw::RawDocument;
7777
//!
7878
//! let bytes = b"\x13\x00\x00\x00\x02hi\x00\x06\x00\x00\x00y'all\x00\x00";
79-
//! assert_eq!(RawDocument::from_bytes(bytes)?.get_str("hi")?, "y'all");
79+
//! assert_eq!(RawDocument::decode_from_bytes(bytes)?.get_str("hi")?, "y'all");
8080
//! # Ok::<(), Box<dyn std::error::Error>>(())
8181
//! ```
8282
//!

src/raw/array.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ use crate::{
3737
/// let doc = doc! {
3838
/// "x": [1, true, "two", 5.5]
3939
/// };
40-
/// let bytes = bson::to_vec(&doc)?;
40+
/// let bytes = bson::serialize_to_vec(&doc)?;
4141
///
42-
/// let rawdoc = RawDocument::from_bytes(bytes.as_slice())?;
42+
/// let rawdoc = RawDocument::decode_from_bytes(bytes.as_slice())?;
4343
/// let rawarray = rawdoc.get_array("x")?;
4444
///
4545
/// for v in rawarray {
@@ -59,9 +59,9 @@ use crate::{
5959
/// let doc = doc! {
6060
/// "x": [1, true, "two", 5.5]
6161
/// };
62-
/// let bytes = bson::to_vec(&doc)?;
62+
/// let bytes = doc.encode_to_vec()?;
6363
///
64-
/// let rawdoc = RawDocument::from_bytes(bytes.as_slice())?;
64+
/// let rawdoc = RawDocument::decode_from_bytes(bytes.as_slice())?;
6565
/// let rawarray = rawdoc.get_array("x")?;
6666
///
6767
/// assert_eq!(rawarray.get_bool(1)?, true);

src/raw/document.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ use crate::{oid::ObjectId, spec::ElementType, Document};
4646
/// # use bson::error::Error;
4747
/// use bson::raw::RawDocument;
4848
///
49-
/// let doc = RawDocument::from_bytes(b"\x13\x00\x00\x00\x02hi\x00\x06\x00\x00\x00y'all\x00\x00")?;
49+
/// let doc = RawDocument::decode_from_bytes(b"\x13\x00\x00\x00\x02hi\x00\x06\x00\x00\x00y'all\x00\x00")?;
5050
/// let mut iter = doc.into_iter();
5151
/// let (key, value) = iter.next().unwrap()?;
5252
/// assert_eq!(key, "hi");
@@ -63,7 +63,7 @@ use crate::{oid::ObjectId, spec::ElementType, Document};
6363
/// ```
6464
/// use bson::raw::RawDocument;
6565
///
66-
/// let doc = RawDocument::from_bytes(b"\x13\x00\x00\x00\x02hi\x00\x06\x00\x00\x00y'all\x00\x00")?;
66+
/// let doc = RawDocument::decode_from_bytes(b"\x13\x00\x00\x00\x02hi\x00\x06\x00\x00\x00y'all\x00\x00")?;
6767
/// assert_eq!(doc.get_str("hi")?, "y'all");
6868
/// # Ok::<(), Box<dyn std::error::Error>>(())
6969
/// ```
@@ -89,7 +89,7 @@ impl RawDocument {
8989
/// ```
9090
/// use bson::raw::RawDocument;
9191
///
92-
/// let doc = RawDocument::from_bytes(b"\x05\0\0\0\0")?;
92+
/// let doc = RawDocument::decode_from_bytes(b"\x05\0\0\0\0")?;
9393
/// # Ok::<(), bson::error::Error>(())
9494
/// ```
9595
pub fn decode_from_bytes<D: AsRef<[u8]> + ?Sized>(data: &D) -> RawResult<&RawDocument> {
@@ -132,7 +132,7 @@ impl RawDocument {
132132
/// use bson::raw::{RawDocument, RawDocumentBuf};
133133
///
134134
/// let data = b"\x05\0\0\0\0";
135-
/// let doc_ref = RawDocument::from_bytes(data)?;
135+
/// let doc_ref = RawDocument::decode_from_bytes(data)?;
136136
/// let doc: RawDocumentBuf = doc_ref.to_raw_document_buf();
137137
/// # Ok::<(), bson::error::Error>(())
138138
pub fn to_raw_document_buf(&self) -> RawDocumentBuf {

src/raw/document_buf.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ mod raw_writer;
2424
/// # use bson::error::Error;
2525
/// use bson::raw::RawDocumentBuf;
2626
///
27-
/// let doc = RawDocumentBuf::from_bytes(b"\x13\x00\x00\x00\x02hi\x00\x06\x00\x00\x00y'all\x00\x00".to_vec())?;
27+
/// let doc = RawDocumentBuf::decode_from_bytes(b"\x13\x00\x00\x00\x02hi\x00\x06\x00\x00\x00y'all\x00\x00".to_vec())?;
2828
/// let mut iter = doc.iter();
2929
/// let (key, value) = iter.next().unwrap()?;
3030
/// assert_eq!(key, "hi");
@@ -42,7 +42,7 @@ mod raw_writer;
4242
/// ```
4343
/// use bson::raw::RawDocumentBuf;
4444
///
45-
/// let doc = RawDocumentBuf::from_bytes(b"\x13\x00\x00\x00\x02hi\x00\x06\x00\x00\x00y'all\x00\x00".to_vec())?;
45+
/// let doc = RawDocumentBuf::decode_from_bytes(b"\x13\x00\x00\x00\x02hi\x00\x06\x00\x00\x00y'all\x00\x00".to_vec())?;
4646
/// assert_eq!(doc.get_str("hi")?, "y'all");
4747
/// # Ok::<(), Box<dyn std::error::Error>>(())
4848
/// ```
@@ -74,7 +74,7 @@ impl RawDocumentBuf {
7474
///
7575
/// ```
7676
/// # use bson::raw::RawDocumentBuf;
77-
/// let doc = RawDocumentBuf::from_bytes(b"\x05\0\0\0\0".to_vec())?;
77+
/// let doc = RawDocumentBuf::decode_from_bytes(b"\x05\0\0\0\0".to_vec())?;
7878
/// # Ok::<(), bson::error::Error>(())
7979
/// ```
8080
pub fn decode_from_bytes(data: Vec<u8>) -> Result<Self> {

src/ser.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ where
172172
/// }
173173
///
174174
/// let cat = Cat { name: "Garfield".to_string(), age: 43 };
175-
/// let doc = bson::to_raw_document_buf(&cat)?;
175+
/// let doc = bson::serialize_to_raw_document_buf(&cat)?;
176176
/// assert_eq!(doc, rawdoc! { "name": "Garfield", "age": 43 });
177177
/// # Ok::<(), Box<dyn std::error::Error>>(())
178178
/// ```

0 commit comments

Comments
 (0)