BlockBuilder

Struct BlockBuilder 

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

Builder for creating Block instances with fluent API

§Example

use blocks::builders::BlockBuilder;

let block = BlockBuilder::text("Hello World")
    .with_metadata("author", "John Doe")
    .build();

Implementations§

Source§

impl BlockBuilder

Source

pub fn text(content: impl Into<String>) -> Self

Creates a new text block builder

Source

pub fn header(level: u8, content: impl Into<String>) -> Result<Self>

Creates a new header block builder

Source

pub fn code(content: impl Into<String>, language: Option<String>) -> Self

Creates a new code block builder

Source

pub fn quote(content: impl Into<String>) -> Self

Creates a new quote block builder

Source

pub fn list(content: impl Into<String>, list_type: ListType) -> Self

Creates a new list block builder

Source

pub fn unordered_list(content: impl Into<String>) -> Self

Creates a new unordered list block builder

Source

pub fn ordered_list(content: impl Into<String>) -> Self

Creates a new ordered list block builder

Creates a new link block builder

Source

pub fn image( url: impl Into<String>, alt: impl Into<String>, caption: Option<String>, ) -> Result<Self>

Creates a new image block builder

Source

pub fn button( text: impl Into<String>, url: impl Into<String>, style: ButtonStyle, ) -> Result<Self>

Creates a new button block builder

Source

pub fn callout( callout_type: CalloutType, title: Option<String>, content: impl Into<String>, ) -> Self

Creates a new callout block builder

Source

pub fn divider() -> Self

Creates a new divider block builder

Source

pub fn table( headers: Vec<String>, rows: Vec<Vec<String>>, has_header: bool, ) -> Self

Creates a new table block builder

Source

pub fn embed( embed_type: EmbedType, url: impl Into<String>, width: Option<u32>, height: Option<u32>, ) -> Result<Self>

Creates a new embed block builder

Source

pub fn details( summary: impl Into<String>, content: impl Into<String>, is_open: bool, ) -> Self

Creates a new details (collapsible) block builder

Source

pub fn with_metadata( self, key: impl Into<String>, value: impl Into<String>, ) -> Self

Adds metadata to the block

Source

pub fn with_metadata_map(self, metadata: HashMap<String, String>) -> Self

Adds multiple metadata entries

Source

pub fn build(self) -> Block

Builds the block

Auto Trait Implementations§

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn into(self) -> U

Calls U::from(self).

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

§

impl<T, U> TryFrom<U> for T
where 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>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where 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>

Performs the conversion.