INNER CODE UNIT · Rust

from_base64

mongodb/bson-rust · src/binary.rs:53

    pub fn from_base64(
        input: impl AsRef<str>,
        subtype: impl Into<Option<BinarySubtype>>,
    ) -> Result<Self> {
        let bytes = base64::decode(input.as_ref()).map_err(Error::binary)?;
        let subtype = match subtype.into() {
            Some(s) => s,
            None => BinarySubtype::Generic,
        };
        Ok(Binary { subtype, bytes })
    }

    #[cfg(feature = "serde")]
    pub(crate) fn from_extended_doc(doc: &crate::Document) -> Option<Self> {
        use std::convert::TryFrom;

        let binary_doc = doc.get_document("$binary").ok()?;

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…