pub enum Unknown {
Object(BTreeMap<String, DataModel>),
Null,
Other(DataModel),
}
Expand description
Arbitrary data with no specific validation and no type-specific fields.
Corresponds to the unknown
field type.
By using the TryFromUnknown
trait, it is possible to convert to any type
that implements DeserializeOwned
.
use atrium_api::types::{TryFromUnknown, Unknown};
#[derive(Debug, serde::Deserialize)]
struct Foo {
bar: i32,
}
let value: Unknown = serde_json::from_str(r#"{"bar": 42}"#)?;
println!("{value:?}"); // Object({"bar": DataModel(42)})
let foo = Foo::try_from_unknown(value)?;
println!("{foo:?}"); // Foo { bar: 42 }
Variants§
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Unknown
impl<'de> Deserialize<'de> for Unknown
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for Unknown
impl StructuralPartialEq for Unknown
Auto Trait Implementations§
impl Freeze for Unknown
impl RefUnwindSafe for Unknown
impl Send for Unknown
impl Sync for Unknown
impl Unpin for Unknown
impl UnwindSafe for Unknown
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.