#[cfg(feature = "kinds")]
pub mod kind;
#[cfg(feature = "types")]
pub mod properties;
#[cfg(feature = "types")]
mod types;
#[cfg(feature = "types")]
pub use self::types::{
Article, Audio, Document, Event, Image, Note, Page, Place, Profile, Relationship, Tombstone,
Video,
};
#[cfg_attr(feature = "derive", crate::wrapper_type)]
pub trait Object: crate::Base {}
#[cfg(feature = "types")]
#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]
pub struct AnyImage {
#[serde(rename = "type")]
kind: self::kind::ImageType,
#[serde(flatten)]
rest: std::collections::HashMap<String, serde_json::Value>,
}
#[cfg(feature = "types")]
impl AnyImage {
pub fn from_concrete<T>(t: T) -> Result<Self, serde_json::Error>
where
T: Object + serde::ser::Serialize,
{
serde_json::from_value(serde_json::to_value(t)?)
}
pub fn into_concrete<T>(self) -> Result<T, serde_json::Error>
where
T: Object + serde::de::DeserializeOwned,
{
serde_json::from_value(serde_json::to_value(self)?)
}
}