Enum gray_matter::Pod
source · [−]pub enum Pod {
Null,
String(String),
Integer(i64),
Float(f64),
Boolean(bool),
Array(Vec<Pod>),
Hash(HashMap<String, Pod>),
}
Expand description
A polyglot data type for representing the parsed front matter.
Any Engine
has to convert the data represented by the format into a
Pod
. This ensures we can use the parsed data similarly, regardless of the format it is parsed
from.
Variants
Null
String(String)
Integer(i64)
Float(f64)
Boolean(bool)
Array(Vec<Pod>)
Hash(HashMap<String, Pod>)
Implementations
sourceimpl Pod
impl Pod
sourcepub fn deserialize<T: DeserializeOwned>(&self) -> Result<T>
pub fn deserialize<T: DeserializeOwned>(&self) -> Result<T>
Deserialize a Pod
into any struct that implements
Deserialize
.
Note: The function coerces self
into a
serde_json::Value
in
order to work around implementing a custom Deserializer
for Pod
.
pub fn new_array() -> Pod
pub fn new_hash() -> Pod
sourcepub fn push<T>(&mut self, value: T) -> Result<(), Error> where
T: Into<Pod>,
pub fn push<T>(&mut self, value: T) -> Result<(), Error> where
T: Into<Pod>,
Pushes a new value into Pod::Array
.
sourcepub fn insert<T>(&mut self, key: String, val: T) -> Result<(), Error> where
T: Into<Pod>,
pub fn insert<T>(&mut self, key: String, val: T) -> Result<(), Error> where
T: Into<Pod>,
Inserts a key value pair into or override the exist one in Pod::Hash.
sourcepub fn remove(&mut self, key: String) -> Pod
pub fn remove(&mut self, key: String) -> Pod
Removes the value of specific key from Pod::Hash and returns it or null if not exists.
sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Returns length of Pod::Array and Pod::Hash, 0 as default for other types.
pub fn is_empty(&self) -> bool
pub fn as_string(&self) -> Result<String, Error>
pub fn as_i64(&self) -> Result<i64, Error>
pub fn as_f64(&self) -> Result<f64, Error>
pub fn as_bool(&self) -> Result<bool, Error>
pub fn as_vec(&self) -> Result<Vec<Pod>, Error>
pub fn as_hashmap(&self) -> Result<HashMap<String, Pod>, Error>
Trait Implementations
impl StructuralPartialEq for Pod
Auto Trait Implementations
impl RefUnwindSafe for Pod
impl Send for Pod
impl Sync for Pod
impl Unpin for Pod
impl UnwindSafe for Pod
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more