Struct Document

Source
pub struct Document { /* private fields */ }
Expand description

The root document itself, this contains a list of BlockContent values as well as a list of metadata properties.

Note that the add_ and set_ methods all return &mut Self and so calls to these may be chained.

Implementations§

Source§

impl Document

Source

pub fn has_metadata(&self) -> bool

Returns true if this document has any associated metadata, else false.

Source

pub fn metadata(&self) -> &Vec<Metadata>

Return the list of associated metadata.

Source

pub fn add_metadata(&mut self, datum: Metadata) -> &mut Self

Add a metadata item to this document.

Source

pub fn set_title(&mut self, v: &str) -> &mut Self

Set the title (metadata value) of this document.

Source

pub fn set_date(&mut self, v: &str) -> &mut Self

Set the date (metadata value) of this document.

Source

pub fn add_author(&mut self, v: Author) -> &mut Self

Add an author (metadata value) to this document.

Source

pub fn add_author_str( &mut self, name: &str, email: Option<&str>, organization: Option<&str>, ) -> &mut Self

Add an author (metadata value) to this document.

Add a copyright (metadata value) to this document.

Add a copyright (metadata value) to this document.

Source

pub fn add_keywords(&mut self, v: &[String]) -> &mut Self

Add a list of keywords (metadata value) to this document.

Source

pub fn add_keywords_str(&mut self, v: &[&str]) -> &mut Self

Add a list of keywords (metadata value) to this document.

Source

pub fn add_metadata_property(&mut self, v: SimpleProperty) -> &mut Self

Add an arbitrary, named, metadata value)to this document.

Source

pub fn add_metadata_property_str( &mut self, name: &str, value: &str, ) -> &mut Self

Add an arbitrary, named, metadata value)to this document.

Source

pub fn has_abstract(&self) -> bool

Returns true if an abstract has been added to this document, else false.

Source

pub fn add_abstract(&mut self, abstract_block: Paragraph) -> &mut Self

Add a Paragraph acting as the abstract to this document.

Source

pub fn abstract_block(&self) -> &Option<Paragraph>

Return the Paragraph, if present, acting as the abstract to this document.

Trait Implementations§

Source§

impl Clone for Document

Source§

fn clone(&self) -> Document

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Document

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Document

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Document

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl HasBlockContent for Document

Source§

fn from(inner: BlockContent) -> Self

Create a new block content container from the provided content item.
Source§

fn comment(inner: String) -> Self

Create a new block content container from the provided String content item.
Source§

fn front_matter(matter: FrontMatter) -> Self

Create a new block content container from the provided FrontMatter content item.
Source§

fn heading(inner: Heading) -> Self

Create a new block content container from the provided Heading content item.
Source§

fn image(inner: ImageBlock) -> Self

Create a new block content container from the provided ImageBlock content item.
Source§

fn math(inner: MathBlock) -> Self

Create a new block content container from the provided MathBlock content item.
Source§

fn list(inner: List) -> Self

Create a new block content container from the provided List content item.
Source§

fn definition_list(inner: DefinitionList) -> Self

Create a new block content container from the provided DefinitionList content item.
Source§

fn formatted(inner: Formatted) -> Self

Create a new block content container from the provided Formatted content item.
Source§

fn code_block(inner: CodeBlock) -> Self

Create a new block content container from the provided CodeBlock content item.
Source§

fn paragraph(inner: Paragraph) -> Self

Create a new block content container from the provided Paragraph content item.
Source§

fn block_quote(inner: Quote) -> Self

Create a new block content container from the provided Quote content item.
Source§

fn table(inner: Table) -> Self

Create a new block content container from the provided Table content item.
Source§

fn thematic_break() -> Self

Create a new block content container with a thematic break.
Source§

fn add_comment_str(&mut self, inner: &str) -> &mut Self

Add the provided Comment to this container’s inner content.
Source§

fn add_front_matter(&mut self, matter: FrontMatter) -> &mut Self

Add the provided FrontMatter to this container’s inner content.
Source§

fn add_heading(&mut self, inner: Heading) -> &mut Self

Add the provided Heading to this container’s inner content.
Source§

fn add_image(&mut self, inner: ImageBlock) -> &mut Self

Add the provided ImageBlock to this container’s inner content.
Source§

fn add_math(&mut self, inner: MathBlock) -> &mut Self

Add the provided MathBlock to this container’s inner content.
Source§

fn add_list(&mut self, inner: List) -> &mut Self

Add the provided List to this container’s inner content.
Source§

fn add_definition_list(&mut self, inner: DefinitionList) -> &mut Self

Add the provided DefinitionList to this container’s inner content.
Source§

fn add_formatted(&mut self, inner: Formatted) -> &mut Self

Add the provided Formatted to this container’s inner content.
Source§

fn add_code_block(&mut self, inner: CodeBlock) -> &mut Self

Add the provided CodeBlock to this container’s inner content.
Source§

fn add_paragraph(&mut self, inner: Paragraph) -> &mut Self

Add the provided Paragraph to this container’s inner content.
Source§

fn add_block_quote(&mut self, inner: Quote) -> &mut Self

Add the provided Quote to this container’s inner content.
Source§

fn add_table(&mut self, inner: Table) -> &mut Self

Add the provided Table to this container’s inner content.
Source§

fn add_thematic_break(&mut self) -> &mut Self

Add a ThematicBreak to this container’s inner content.
Source§

impl HasInnerContent<BlockContent> for Document

Source§

fn inner(&self) -> &Vec<BlockContent>

Return a reference to the inner value.
Source§

fn into_inner(self) -> Vec<BlockContent>

Return the inner value, consuming self.
Source§

fn inner_mut(&mut self) -> &mut Vec<BlockContent>

Return a mutable reference to the inner list of content.
Source§

fn add_content(&mut self, content: BlockContent) -> Result<()>

Add content to the inner list of content. If there is some consistency condition that would be broken by this addition an error will be returned.
Source§

fn has_inner(&self) -> bool

Returns true if the inner list of content is not empty, else false.
Source§

impl Into<Document> for BlockContent

Source§

fn into(self) -> Document

Converts this type into the (usually inferred) input type.
Source§

impl Serialize for Document

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,