pub struct MarkdownToParts<'a> { /* private fields */ }
Expand description
Converts markdown to parts considering 
means Gemini will be see the images too. link
can be URL or file path.
Implementations§
Source§impl<'a> MarkdownToParts<'a>
impl<'a> MarkdownToParts<'a>
pub fn base64s(&self) -> &Vec<MatchedFiles>
Source§impl<'a> MarkdownToParts<'a>
impl<'a> MarkdownToParts<'a>
pub fn builder() -> MarkdownToPartsBuilder
Sourcepub async fn from_regex_checked(
markdown: &'a str,
regex: Regex,
guess_mime_type: fn(url: &str) -> Mime,
decide_download: fn(headers: &HeaderMap) -> bool,
) -> Self
pub async fn from_regex_checked( markdown: &'a str, regex: Regex, guess_mime_type: fn(url: &str) -> Mime, decide_download: fn(headers: &HeaderMap) -> bool, ) -> Self
§Panics
regex
must have a Regex with only 1 capture group with file URL as first capture
group, else it PANICS.
§Arguments
guess_mime_type
is used to detect mimi_type of URL pointing to file system or web resource
with no “Content-Type” header.
decide_download
is used to decide if to download. If it returns false, resource will not
be fetched and won’t be in parts
§Example
from_regex("Your markdown string...", Regex::new(r"(?s)!\[.*?].?\((.*?)\)").unwrap(), |_| mime::IMAGE_PNG, |_| true)
Sourcepub async fn from_regex(
markdown: &'a str,
regex: Regex,
guess_mime_type: fn(url: &str) -> Mime,
) -> Self
pub async fn from_regex( markdown: &'a str, regex: Regex, guess_mime_type: fn(url: &str) -> Mime, ) -> Self
§Panics
regex
must have a Regex with only 1 capture group with file URL as first capture group, else it PANICS.
§Arguments
guess_mime_type
is used to detect mimi_type of URL pointing to file system or web resource
with no “Content-Type” header.
§Example
from_regex("Your markdown string...", Regex::new(r"(?s)!\[.*?].?\((.*?)\)").unwrap(), |_|
mime::IMAGE_PNG)
Sourcepub async fn new_checked(
markdown: &'a str,
guess_mime_type: fn(url: &str) -> Mime,
decide_download: fn(headers: &HeaderMap) -> bool,
) -> Self
pub async fn new_checked( markdown: &'a str, guess_mime_type: fn(url: &str) -> Mime, decide_download: fn(headers: &HeaderMap) -> bool, ) -> Self
§Arguments
guess_mime_type
is used to detect mimi_type of URL pointing to file system or web resource
with no “Content-Type” header.
decide_download
is used to decide if to download. If it returns false, resource will not
be fetched and won’t be in parts
§Example
new("Your markdown string...", |_| mime::IMAGE_PNG, |_| true)
pub fn process(self) -> Vec<Part>
Trait Implementations§
Source§impl<'a> Clone for MarkdownToParts<'a>
impl<'a> Clone for MarkdownToParts<'a>
Source§fn clone(&self) -> MarkdownToParts<'a>
fn clone(&self) -> MarkdownToParts<'a>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more