[−][src]Struct bloguen::ops::PostMetadata
Generic post metadata.
Fields
language: Option<LanguageTag>
Post language override.
If not present, default post language is used.
Post author override.
If not present, default post author is used.
A set of tags.
If not present, defaults to empty.
styles: Vec<StyleElement>
A set of style descriptors.
If not present, defaults to empty.
scripts: Vec<ScriptElement>
A set of style descriptors.
If not present, defaults to empty.
data: BTreeMap<String, String>
Additional static data to substitute in header and footer.
If not present, defaults to empty.
Methods
impl PostMetadata
[src]
pub fn read_or_default(
post_root: &(String, PathBuf)
) -> Result<PostMetadata, Error>
[src]
post_root: &(String, PathBuf)
) -> Result<PostMetadata, Error>
Read the post metadata from the specified root directory.
If the metadata file doesn't exist, Ok(Default::default())
is returned.
Examples
Given $POST_ROOT/metadata.toml
containing:
language = "pl"
tags = ["vodka", "depression"]
[[scripts]]
class = "link"
data = "/content/assets/syllable.js"
[[scripts]]
class = "file"
data = "MathJax-config.js"
[data]
desc = "Każdy koniec to nowy początek [PL]"
The following holds:
let post_root: PathBuf = /* obtained elsewhere */; let metadata = PostMetadata::read_or_default(&("$POST_ROOT/".to_string(), post_root.clone())).unwrap(); assert_eq!(metadata, PostMetadata { language: Some("pl".parse().unwrap()), author: None, tags: vec!["vodka".parse().unwrap(), "depression".parse().unwrap()], styles: vec![], scripts: vec![ScriptElement::from_link("/content/assets/syllable.js"), ScriptElement::from_path("MathJax-config.js")], data: vec![("desc".to_string(), "Każdy koniec to nowy początek [PL]".to_string())] .into_iter().collect(), });
Trait Implementations
impl Eq for PostMetadata
[src]
impl Default for PostMetadata
[src]
fn default() -> PostMetadata
[src]
impl Clone for PostMetadata
[src]
fn clone(&self) -> PostMetadata
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl PartialOrd<PostMetadata> for PostMetadata
[src]
fn partial_cmp(&self, other: &PostMetadata) -> Option<Ordering>
[src]
fn lt(&self, other: &PostMetadata) -> bool
[src]
fn le(&self, other: &PostMetadata) -> bool
[src]
fn gt(&self, other: &PostMetadata) -> bool
[src]
fn ge(&self, other: &PostMetadata) -> bool
[src]
impl PartialEq<PostMetadata> for PostMetadata
[src]
fn eq(&self, other: &PostMetadata) -> bool
[src]
fn ne(&self, other: &PostMetadata) -> bool
[src]
impl Ord for PostMetadata
[src]
fn cmp(&self, other: &PostMetadata) -> Ordering
[src]
fn max(self, other: Self) -> Self
1.21.0[src]
fn min(self, other: Self) -> Self
1.21.0[src]
fn clamp(self, min: Self, max: Self) -> Self
[src]
impl Hash for PostMetadata
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl Debug for PostMetadata
[src]
Auto Trait Implementations
impl Send for PostMetadata
impl Unpin for PostMetadata
impl Sync for PostMetadata
impl UnwindSafe for PostMetadata
impl RefUnwindSafe for PostMetadata
Blanket Implementations
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
[src]
V: MultiLane<T>,