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
impl BlockBuilder
Sourcepub fn header(level: u8, content: impl Into<String>) -> Result<Self>
pub fn header(level: u8, content: impl Into<String>) -> Result<Self>
Creates a new header block builder
Sourcepub fn code(content: impl Into<String>, language: Option<String>) -> Self
pub fn code(content: impl Into<String>, language: Option<String>) -> Self
Creates a new code block builder
Sourcepub fn list(content: impl Into<String>, list_type: ListType) -> Self
pub fn list(content: impl Into<String>, list_type: ListType) -> Self
Creates a new list block builder
Sourcepub fn unordered_list(content: impl Into<String>) -> Self
pub fn unordered_list(content: impl Into<String>) -> Self
Creates a new unordered list block builder
Sourcepub fn ordered_list(content: impl Into<String>) -> Self
pub fn ordered_list(content: impl Into<String>) -> Self
Creates a new ordered list block builder
Sourcepub fn link(
text: impl Into<String>,
url: impl Into<String>,
title: Option<String>,
) -> Result<Self>
pub fn link( text: impl Into<String>, url: impl Into<String>, title: Option<String>, ) -> Result<Self>
Creates a new link block builder
Sourcepub fn image(
url: impl Into<String>,
alt: impl Into<String>,
caption: Option<String>,
) -> Result<Self>
pub fn image( url: impl Into<String>, alt: impl Into<String>, caption: Option<String>, ) -> Result<Self>
Creates a new image block builder
Creates a new button block builder
Sourcepub fn callout(
callout_type: CalloutType,
title: Option<String>,
content: impl Into<String>,
) -> Self
pub fn callout( callout_type: CalloutType, title: Option<String>, content: impl Into<String>, ) -> Self
Creates a new callout block builder
Sourcepub fn table(
headers: Vec<String>,
rows: Vec<Vec<String>>,
has_header: bool,
) -> Self
pub fn table( headers: Vec<String>, rows: Vec<Vec<String>>, has_header: bool, ) -> Self
Creates a new table block builder
Sourcepub fn embed(
embed_type: EmbedType,
url: impl Into<String>,
width: Option<u32>,
height: Option<u32>,
) -> Result<Self>
pub fn embed( embed_type: EmbedType, url: impl Into<String>, width: Option<u32>, height: Option<u32>, ) -> Result<Self>
Creates a new embed block builder
Sourcepub fn details(
summary: impl Into<String>,
content: impl Into<String>,
is_open: bool,
) -> Self
pub fn details( summary: impl Into<String>, content: impl Into<String>, is_open: bool, ) -> Self
Creates a new details (collapsible) block builder
Sourcepub fn with_metadata(
self,
key: impl Into<String>,
value: impl Into<String>,
) -> Self
pub fn with_metadata( self, key: impl Into<String>, value: impl Into<String>, ) -> Self
Adds metadata to the block
Sourcepub fn with_metadata_map(self, metadata: HashMap<String, String>) -> Self
pub fn with_metadata_map(self, metadata: HashMap<String, String>) -> Self
Adds multiple metadata entries