Skip to main content

Block

Enum Block 

Source
#[non_exhaustive]
pub enum Block {
#[non_exhaustive]
Text { content: String, footnotes: Vec<Footnote>, },
#[non_exhaustive]
Quote { content: String, footnotes: Vec<Footnote>, },
#[non_exhaustive]
Title { content: String, footnotes: Vec<Footnote>, level: usize, },
#[non_exhaustive]
Image { url: PathBuf, alt: Option<String>, caption: Option<String>, footnotes: Vec<Footnote>, },
#[non_exhaustive]
Audio { url: PathBuf, fallback: String, caption: Option<String>, footnotes: Vec<Footnote>, },
#[non_exhaustive]
Video { url: PathBuf, fallback: String, caption: Option<String>, footnotes: Vec<Footnote>, },
#[non_exhaustive]
MathML { element_str: String, fallback_image: Option<PathBuf>, caption: Option<String>, footnotes: Vec<Footnote>, }, }
Expand description

Content Block

The content block is the basic unit of content in a content document. It can be one of the following types: Text, Quote, Title, Image, Audio, Video, MathML.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

#[non_exhaustive]
Text

Text paragraph

This block represents a paragraph of text.

Fields

This variant is marked as non-exhaustive
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§content: String
§footnotes: Vec<Footnote>
§

#[non_exhaustive]
Quote

Quote paragraph

This block represents a paragraph of quoted text.

Fields

This variant is marked as non-exhaustive
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§content: String
§footnotes: Vec<Footnote>
§

#[non_exhaustive]
Title

Heading

Fields

This variant is marked as non-exhaustive
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§content: String
§footnotes: Vec<Footnote>
§level: usize

Heading level

The valid range is 1 to 6.

§

#[non_exhaustive]
Image

Image block

Fields

This variant is marked as non-exhaustive
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§url: PathBuf

Image file path

§alt: Option<String>

Alternative text for the image

§caption: Option<String>

Caption for the image

§footnotes: Vec<Footnote>
§

#[non_exhaustive]
Audio

Audio block

Fields

This variant is marked as non-exhaustive
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§url: PathBuf

Audio file path

§fallback: String

Fallback text for the audio

This is used when the audio file cannot be played.

§caption: Option<String>

Caption for the audio

§footnotes: Vec<Footnote>
§

#[non_exhaustive]
Video

Video block

Fields

This variant is marked as non-exhaustive
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§url: PathBuf

Video file path

§fallback: String

Fallback text for the video

This is used when the video file cannot be played.

§caption: Option<String>

Caption for the video

§footnotes: Vec<Footnote>
§

#[non_exhaustive]
MathML

MathML block

Fields

This variant is marked as non-exhaustive
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§element_str: String

MathML element raw data

This field stores the raw data of the MathML markup, which we do not verify, and the user needs to make sure it is correct.

§fallback_image: Option<PathBuf>

Fallback image for the MathML block

This field stores the path to the fallback image, which will be displayed when the MathML markup cannot be rendered.

§caption: Option<String>

Caption for the MathML block

§footnotes: Vec<Footnote>

Implementations§

Trait Implementations§

Source§

impl Debug for Block

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Block

§

impl RefUnwindSafe for Block

§

impl Send for Block

§

impl Sync for Block

§

impl Unpin for Block

§

impl UnwindSafe for Block

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> 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> Same for T

Source§

type Output = T

Should always be Self
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.