Struct bson::raw::RawDocumentBuf

source ·
pub struct RawDocumentBuf { /* private fields */ }
Expand description

An owned BSON document (akin to std::path::PathBuf), backed by a buffer of raw BSON bytes. This can be created from a Vec<u8> or a crate::Document.

Accessing elements within a RawDocumentBuf is similar to element access in crate::Document, but because the contents are parsed during iteration instead of at creation time, format errors can happen at any time during use.

Iterating over a RawDocumentBuf yields either an error or a key-value pair that borrows from the original document without making any additional allocations.

use bson::raw::RawDocumentBuf;

let doc = RawDocumentBuf::from_bytes(b"\x13\x00\x00\x00\x02hi\x00\x06\x00\x00\x00y'all\x00\x00".to_vec())?;
let mut iter = doc.iter();
let (key, value) = iter.next().unwrap()?;
assert_eq!(key, "hi");
assert_eq!(value.as_str(), Some("y'all"));
assert!(iter.next().is_none());

This type implements Deref to RawDocument, meaning that all methods on RawDocument are available on RawDocumentBuf values as well. This includes RawDocument::get or any of the type-specific getters, such as RawDocument::get_object_id or RawDocument::get_str. Note that accessing elements is an O(N) operation, as it requires iterating through the document from the beginning to find the requested key.

use bson::raw::RawDocumentBuf;

let doc = RawDocumentBuf::from_bytes(b"\x13\x00\x00\x00\x02hi\x00\x06\x00\x00\x00y'all\x00\x00".to_vec())?;
assert_eq!(doc.get_str("hi")?, "y'all");

Implementations§

source§

impl RawDocumentBuf

source

pub fn new() -> RawDocumentBuf

Creates a new, empty RawDocumentBuf.

source

pub fn from_bytes(data: Vec<u8>) -> Result<RawDocumentBuf>

Constructs a new RawDocumentBuf, validating only the following invariants:

  • data is at least five bytes long (the minimum for a valid BSON document)
  • the initial four bytes of data accurately represent the length of the bytes as required by the BSON spec.
  • the last byte of data is a 0

Note that the internal structure of the bytes representing the BSON elements is not validated at all by this method. If the bytes do not conform to the BSON spec, then method calls on the RawDocument will return Errors where appropriate.

let doc = RawDocumentBuf::from_bytes(b"\x05\0\0\0\0".to_vec())?;
source

pub fn from_document(doc: &Document) -> Result<RawDocumentBuf>

Create a RawDocumentBuf from a Document.

use bson::{doc, oid::ObjectId, raw::RawDocumentBuf};

let document = doc! {
    "_id": ObjectId::new(),
    "name": "Herman Melville",
    "title": "Moby-Dick",
};
let doc = RawDocumentBuf::from_document(&document)?;
source

pub fn iter(&self) -> Iter<'_>

Gets an iterator over the elements in the RawDocumentBuf, which yields Result<(&str, RawBson<'_>)>.

use bson::{doc, raw::RawDocumentBuf};

let doc = RawDocumentBuf::from_document(&doc! { "ferris": true })?;

for element in doc.iter() {
    let (key, value) = element?;
    assert_eq!(key, "ferris");
    assert_eq!(value.as_bool(), Some(true));
}
§Note:

There is no owning iterator for RawDocumentBuf. If you need ownership over elements that might need to allocate, you must explicitly convert them to owned types yourself.

source

pub fn iter_elements(&self) -> RawIter<'_>

Gets an iterator over the elements in the RawDocumentBuf, which yields Result<RawElement<'_>> values. These hold a reference to the underlying document but do not explicitly resolve the values.

This iterator, which underpins the implementation of the default iterator, produces RawElement objects that hold a view onto the document but do not parse out or construct values until the .value() or .try_into() methods are called.

§Note:

There is no owning iterator for RawDocumentBuf. If you need ownership over elements that might need to allocate, you must explicitly convert them to owned types yourself.

source

pub fn into_bytes(self) -> Vec<u8>

Return the contained data as a Vec<u8>

use bson::{doc, raw::RawDocumentBuf};

let doc = RawDocumentBuf::from_document(&doc!{})?;
assert_eq!(doc.into_bytes(), b"\x05\x00\x00\x00\x00".to_vec());
source

pub fn append(&mut self, key: impl AsRef<str>, value: impl Into<RawBson>)

Append a key value pair to the end of the document without checking to see if the key already exists.

It is a user error to append the same key more than once to the same document, and it may result in errors when communicating with MongoDB.

If the provided key contains an interior null byte, this method will panic.

use bson::{doc, raw::RawDocumentBuf};

let mut doc = RawDocumentBuf::new();
doc.append("a string", "some string");
doc.append("an integer", 12_i32);

let mut subdoc = RawDocumentBuf::new();
subdoc.append("a key", true);
doc.append("a document", subdoc);

let expected = doc! {
    "a string": "some string",
    "an integer": 12_i32,
    "a document": { "a key": true },
};

assert_eq!(doc.to_document()?, expected);
source

pub fn append_ref<'a>( &mut self, key: impl AsRef<str>, value: impl Into<RawBsonRef<'a>> )

Append a key value pair to the end of the document without checking to see if the key already exists.

It is a user error to append the same key more than once to the same document, and it may result in errors when communicating with MongoDB.

If the provided key contains an interior null byte, this method will panic.

source

pub fn to_document(&self) -> Result<Document>

Convert this RawDocumentBuf to a Document, returning an error if invalid BSON is encountered.

Methods from Deref<Target = RawDocument>§

source

pub fn to_raw_document_buf(&self) -> RawDocumentBuf

Creates a new RawDocumentBuf with an owned copy of the BSON bytes.

use bson::raw::{RawDocument, RawDocumentBuf, Error};

let data = b"\x05\0\0\0\0";
let doc_ref = RawDocument::from_bytes(data)?;
let doc: RawDocumentBuf = doc_ref.to_raw_document_buf();
source

pub fn get(&self, key: impl AsRef<str>) -> Result<Option<RawBsonRef<'_>>>

Gets a reference to the value corresponding to the given key by iterating until the key is found.

use bson::{rawdoc, oid::ObjectId};

let doc = rawdoc! {
    "_id": ObjectId::new(),
    "f64": 2.5,
};

let element = doc.get("f64")?.expect("finding key f64");
assert_eq!(element.as_f64(), Some(2.5));
assert!(doc.get("unknown")?.is_none());
source

pub fn iter(&self) -> Iter<'_>

Gets an iterator over the elements in the RawDocument that yields Result<(&str, RawBson<'_>)>.

source

pub fn iter_elements(&self) -> RawIter<'_>

Gets an iterator over the elements in the RawDocument, which yields Result<RawElement<'_>> values. These hold a reference to the underlying document but do not explicitly resolve the values.

This iterator, which underpins the implementation of the default iterator, produces RawElement objects that hold a view onto the document but do not parse out or construct values until the .value() or .try_into() methods are called.

source

pub fn get_f64(&self, key: impl AsRef<str>) -> ValueAccessResult<f64>

Gets a reference to the BSON double value corresponding to a given key or returns an error if the key corresponds to a value which isn’t a double.

use bson::raw::ValueAccessErrorKind;
use bson::rawdoc;

let doc = rawdoc! {
    "bool": true,
    "f64": 2.5,
};

assert_eq!(doc.get_f64("f64")?, 2.5);
assert!(matches!(doc.get_f64("bool").unwrap_err().kind, ValueAccessErrorKind::UnexpectedType { .. }));
assert!(matches!(doc.get_f64("unknown").unwrap_err().kind, ValueAccessErrorKind::NotPresent));
source

pub fn get_str(&self, key: impl AsRef<str>) -> ValueAccessResult<&str>

Gets a reference to the string value corresponding to a given key or returns an error if the key corresponds to a value which isn’t a string.

use bson::{rawdoc, raw::ValueAccessErrorKind};

let doc = rawdoc! {
    "string": "hello",
    "bool": true,
};

assert_eq!(doc.get_str("string")?, "hello");
assert!(matches!(doc.get_str("bool").unwrap_err().kind, ValueAccessErrorKind::UnexpectedType { .. }));
assert!(matches!(doc.get_str("unknown").unwrap_err().kind, ValueAccessErrorKind::NotPresent));
source

pub fn get_document( &self, key: impl AsRef<str> ) -> ValueAccessResult<&RawDocument>

Gets a reference to the document value corresponding to a given key or returns an error if the key corresponds to a value which isn’t a document.

use bson::{rawdoc, raw::ValueAccessErrorKind};

let doc = rawdoc! {
    "doc": { "key": "value"},
    "bool": true,
};

assert_eq!(doc.get_document("doc")?.get_str("key")?, "value");
assert!(matches!(doc.get_document("bool").unwrap_err().kind, ValueAccessErrorKind::UnexpectedType { .. }));
assert!(matches!(doc.get_document("unknown").unwrap_err().kind, ValueAccessErrorKind::NotPresent));
source

pub fn get_array(&self, key: impl AsRef<str>) -> ValueAccessResult<&RawArray>

Gets a reference to the array value corresponding to a given key or returns an error if the key corresponds to a value which isn’t an array.

use bson::{rawdoc, raw::ValueAccessErrorKind};

let doc = rawdoc! {
    "array": [true, 3],
    "bool": true,
};

let mut arr_iter = doc.get_array("array")?.into_iter();
let _: bool = arr_iter.next().unwrap()?.as_bool().unwrap();
let _: i32 = arr_iter.next().unwrap()?.as_i32().unwrap();

assert!(arr_iter.next().is_none());
assert!(doc.get_array("bool").is_err());
assert!(matches!(doc.get_array("unknown").unwrap_err().kind, ValueAccessErrorKind::NotPresent));
source

pub fn get_binary( &self, key: impl AsRef<str> ) -> ValueAccessResult<RawBinaryRef<'_>>

Gets a reference to the BSON binary value corresponding to a given key or returns an error if the key corresponds to a value which isn’t a binary value.

use bson::{
    rawdoc,
    raw::ValueAccessErrorKind,
    spec::BinarySubtype,
    Binary,
};

let doc = rawdoc! {
    "binary": Binary { subtype: BinarySubtype::Generic, bytes: vec![1, 2, 3] },
    "bool": true,
};

assert_eq!(&doc.get_binary("binary")?.bytes, &[1, 2, 3]);
assert!(matches!(doc.get_binary("bool").unwrap_err().kind, ValueAccessErrorKind::UnexpectedType { .. }));
assert!(matches!(doc.get_binary("unknown").unwrap_err().kind, ValueAccessErrorKind::NotPresent));
source

pub fn get_object_id(&self, key: impl AsRef<str>) -> ValueAccessResult<ObjectId>

Gets a reference to the ObjectId value corresponding to a given key or returns an error if the key corresponds to a value which isn’t an ObjectId.

use bson::{rawdoc, oid::ObjectId, raw::ValueAccessErrorKind};

let doc = rawdoc! {
    "_id": ObjectId::new(),
    "bool": true,
};

let oid = doc.get_object_id("_id")?;
assert!(matches!(doc.get_object_id("bool").unwrap_err().kind, ValueAccessErrorKind::UnexpectedType { .. }));
assert!(matches!(doc.get_object_id("unknown").unwrap_err().kind, ValueAccessErrorKind::NotPresent));
source

pub fn get_bool(&self, key: impl AsRef<str>) -> ValueAccessResult<bool>

Gets a reference to the boolean value corresponding to a given key or returns an error if the key corresponds to a value which isn’t a boolean.

use bson::{rawdoc, oid::ObjectId, raw::ValueAccessErrorKind};

let doc = rawdoc! {
    "_id": ObjectId::new(),
    "bool": true,
};

assert!(doc.get_bool("bool")?);
assert!(matches!(doc.get_bool("_id").unwrap_err().kind, ValueAccessErrorKind::UnexpectedType { .. }));
assert!(matches!(doc.get_bool("unknown").unwrap_err().kind, ValueAccessErrorKind::NotPresent));
source

pub fn get_datetime(&self, key: impl AsRef<str>) -> ValueAccessResult<DateTime>

Gets a reference to the BSON DateTime value corresponding to a given key or returns an error if the key corresponds to a value which isn’t a DateTime.

use bson::{rawdoc, raw::ValueAccessErrorKind, DateTime};

let dt = DateTime::now();
let doc = rawdoc! {
    "created_at": dt,
    "bool": true,
};

assert_eq!(doc.get_datetime("created_at")?, dt);
assert!(matches!(doc.get_datetime("bool").unwrap_err().kind, ValueAccessErrorKind::UnexpectedType { .. }));
assert!(matches!(doc.get_datetime("unknown").unwrap_err().kind, ValueAccessErrorKind::NotPresent));
source

pub fn get_regex( &self, key: impl AsRef<str> ) -> ValueAccessResult<RawRegexRef<'_>>

Gets a reference to the BSON regex value corresponding to a given key or returns an error if the key corresponds to a value which isn’t a regex.

use bson::{rawdoc, Regex, raw::ValueAccessErrorKind};

let doc = rawdoc! {
    "regex": Regex {
        pattern: r"end\s*$".into(),
        options: "i".into(),
    },
    "bool": true,
};

assert_eq!(doc.get_regex("regex")?.pattern, r"end\s*$");
assert_eq!(doc.get_regex("regex")?.options, "i");
assert!(matches!(doc.get_regex("bool").unwrap_err().kind, ValueAccessErrorKind::UnexpectedType { .. }));
assert!(matches!(doc.get_regex("unknown").unwrap_err().kind, ValueAccessErrorKind::NotPresent));
source

pub fn get_timestamp( &self, key: impl AsRef<str> ) -> ValueAccessResult<Timestamp>

Gets a reference to the BSON timestamp value corresponding to a given key or returns an error if the key corresponds to a value which isn’t a timestamp.

use bson::{rawdoc, Timestamp, raw::ValueAccessErrorKind};

let doc = rawdoc! {
    "bool": true,
    "ts": Timestamp { time: 649876543, increment: 9 },
};

let timestamp = doc.get_timestamp("ts")?;

assert_eq!(timestamp.time, 649876543);
assert_eq!(timestamp.increment, 9);
assert!(matches!(doc.get_timestamp("bool").unwrap_err().kind, ValueAccessErrorKind::UnexpectedType { .. }));
assert!(matches!(doc.get_timestamp("unknown").unwrap_err().kind, ValueAccessErrorKind::NotPresent));
source

pub fn get_i32(&self, key: impl AsRef<str>) -> ValueAccessResult<i32>

Gets a reference to the BSON int32 value corresponding to a given key or returns an error if the key corresponds to a value which isn’t a 32-bit integer.

use bson::{rawdoc, raw::ValueAccessErrorKind};

let doc = rawdoc! {
    "bool": true,
    "i32": 1_000_000,
};

assert_eq!(doc.get_i32("i32")?, 1_000_000);
assert!(matches!(doc.get_i32("bool").unwrap_err().kind, ValueAccessErrorKind::UnexpectedType { ..}));
assert!(matches!(doc.get_i32("unknown").unwrap_err().kind, ValueAccessErrorKind::NotPresent));
source

pub fn get_i64(&self, key: impl AsRef<str>) -> ValueAccessResult<i64>

Gets a reference to the BSON int64 value corresponding to a given key or returns an error if the key corresponds to a value which isn’t a 64-bit integer.

use bson::{rawdoc, raw::ValueAccessErrorKind};

let doc = rawdoc! {
    "bool": true,
    "i64": 9223372036854775807_i64,
};

assert_eq!(doc.get_i64("i64")?, 9223372036854775807);
assert!(matches!(doc.get_i64("bool").unwrap_err().kind, ValueAccessErrorKind::UnexpectedType { .. }));
assert!(matches!(doc.get_i64("unknown").unwrap_err().kind, ValueAccessErrorKind::NotPresent));
source

pub fn as_bytes(&self) -> &[u8]

Return a reference to the contained data as a &[u8]

use bson::rawdoc;
let docbuf = rawdoc! {};
assert_eq!(docbuf.as_bytes(), b"\x05\x00\x00\x00\x00");
source

pub fn is_empty(&self) -> bool

Returns whether this document contains any elements or not.

Trait Implementations§

source§

impl AsRef<RawDocument> for RawDocumentBuf

source§

fn as_ref(&self) -> &RawDocument

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl Borrow<RawDocument> for RawDocumentBuf

source§

fn borrow(&self) -> &RawDocument

Immutably borrows from an owned value. Read more
source§

impl Clone for RawDocumentBuf

source§

fn clone(&self) -> RawDocumentBuf

Returns a copy 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 Debug for RawDocumentBuf

source§

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

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

impl Default for RawDocumentBuf

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl Deref for RawDocumentBuf

§

type Target = RawDocument

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.
source§

impl<'de> Deserialize<'de> for RawDocumentBuf

source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

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

impl<'a> From<&'a RawDocumentBuf> for Cow<'a, RawDocument>

source§

fn from(rd: &'a RawDocumentBuf) -> Self

Converts to this type from the input type.
source§

impl<'a> From<&'a RawDocumentBuf> for RawBsonRef<'a>

source§

fn from(d: &'a RawDocumentBuf) -> Self

Converts to this type from the input type.
source§

impl<'a> From<RawDocumentBuf> for Cow<'a, RawDocument>

source§

fn from(rd: RawDocumentBuf) -> Self

Converts to this type from the input type.
source§

impl From<RawDocumentBuf> for RawBson

source§

fn from(d: RawDocumentBuf) -> Self

Converts to this type from the input type.
source§

impl<S: AsRef<str>, T: Into<RawBson>> FromIterator<(S, T)> for RawDocumentBuf

source§

fn from_iter<I: IntoIterator<Item = (S, T)>>(iter: I) -> Self

Creates a value from an iterator. Read more
source§

impl<'a> IntoIterator for &'a RawDocumentBuf

§

type IntoIter = Iter<'a>

Which kind of iterator are we turning this into?
§

type Item = Result<(&'a str, RawBsonRef<'a>), Error>

The type of the elements being iterated over.
source§

fn into_iter(self) -> Iter<'a>

Creates an iterator from a value. Read more
source§

impl PartialEq for RawDocumentBuf

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for RawDocumentBuf

source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

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

impl TryFrom<&Document> for RawDocumentBuf

§

type Error = Error

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

fn try_from(doc: &Document) -> Result<RawDocumentBuf>

Performs the conversion.
source§

impl TryFrom<RawDocumentBuf> for Document

§

type Error = Error

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

fn try_from(raw: RawDocumentBuf) -> Result<Document>

Performs the conversion.
source§

impl StructuralPartialEq for RawDocumentBuf

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> Conv for T

source§

fn conv<T>(self) -> T
where Self: Into<T>,

Converts self into T using Into<T>. Read more
source§

impl<T> FmtForward for T

source§

fn fmt_binary(self) -> FmtBinary<Self>
where Self: Binary,

Causes self to use its Binary implementation when Debug-formatted.
source§

fn fmt_display(self) -> FmtDisplay<Self>
where Self: Display,

Causes self to use its Display implementation when Debug-formatted.
source§

fn fmt_lower_exp(self) -> FmtLowerExp<Self>
where Self: LowerExp,

Causes self to use its LowerExp implementation when Debug-formatted.
source§

fn fmt_lower_hex(self) -> FmtLowerHex<Self>
where Self: LowerHex,

Causes self to use its LowerHex implementation when Debug-formatted.
source§

fn fmt_octal(self) -> FmtOctal<Self>
where Self: Octal,

Causes self to use its Octal implementation when Debug-formatted.
source§

fn fmt_pointer(self) -> FmtPointer<Self>
where Self: Pointer,

Causes self to use its Pointer implementation when Debug-formatted.
source§

fn fmt_upper_exp(self) -> FmtUpperExp<Self>
where Self: UpperExp,

Causes self to use its UpperExp implementation when Debug-formatted.
source§

fn fmt_upper_hex(self) -> FmtUpperHex<Self>
where Self: UpperHex,

Causes self to use its UpperHex implementation when Debug-formatted.
source§

fn fmt_list(self) -> FmtList<Self>
where &'a Self: for<'a> IntoIterator,

Formats each item in a sequence. 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> Pipe for T
where T: ?Sized,

source§

fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> R
where Self: Sized,

Pipes by value. This is generally the method you want to use. Read more
source§

fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> R
where R: 'a,

Borrows self and passes that borrow into the pipe function. Read more
source§

fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> R
where R: 'a,

Mutably borrows self and passes that borrow into the pipe function. Read more
source§

fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
where Self: Borrow<B>, B: 'a + ?Sized, R: 'a,

Borrows self, then passes self.borrow() into the pipe function. Read more
source§

fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R ) -> R
where Self: BorrowMut<B>, B: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.borrow_mut() into the pipe function. Read more
source§

fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
where Self: AsRef<U>, U: 'a + ?Sized, R: 'a,

Borrows self, then passes self.as_ref() into the pipe function.
source§

fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
where Self: AsMut<U>, U: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.as_mut() into the pipe function.
source§

fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
where Self: Deref<Target = T>, T: 'a + ?Sized, R: 'a,

Borrows self, then passes self.deref() into the pipe function.
source§

fn pipe_deref_mut<'a, T, R>( &'a mut self, func: impl FnOnce(&'a mut T) -> R ) -> R
where Self: DerefMut<Target = T> + Deref, T: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.deref_mut() into the pipe function.
source§

impl<T> Tap for T

source§

fn tap(self, func: impl FnOnce(&Self)) -> Self

Immutable access to a value. Read more
source§

fn tap_mut(self, func: impl FnOnce(&mut Self)) -> Self

Mutable access to a value. Read more
source§

fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Immutable access to the Borrow<B> of a value. Read more
source§

fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Mutable access to the BorrowMut<B> of a value. Read more
source§

fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Immutable access to the AsRef<R> view of a value. Read more
source§

fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Mutable access to the AsMut<R> view of a value. Read more
source§

fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Immutable access to the Deref::Target of a value. Read more
source§

fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Mutable access to the Deref::Target of a value. Read more
source§

fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self

Calls .tap() only in debug builds, and is erased in release builds.
source§

fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self

Calls .tap_mut() only in debug builds, and is erased in release builds.
source§

fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Calls .tap_borrow() only in debug builds, and is erased in release builds.
source§

fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Calls .tap_borrow_mut() only in debug builds, and is erased in release builds.
source§

fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Calls .tap_ref() only in debug builds, and is erased in release builds.
source§

fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Calls .tap_ref_mut() only in debug builds, and is erased in release builds.
source§

fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Calls .tap_deref() only in debug builds, and is erased in release builds.
source§

fn tap_deref_mut_dbg<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Calls .tap_deref_mut() only in debug builds, and is erased in release builds.
source§

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

§

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> TryConv for T

source§

fn try_conv<T>(self) -> Result<T, Self::Error>
where Self: TryInto<T>,

Attempts to convert self into T using TryInto<T>. Read more
source§

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

§

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>,

§

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,