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>
Sourcepub async fn from_regex_checked(
markdown: &'a str,
regex: Regex,
guess_mime_type: fn(url: &str) -> Mime,
decice_download: fn(headers: &HeaderMap) -> bool,
) -> Self
pub async fn from_regex_checked( markdown: &'a str, regex: Regex, guess_mime_type: fn(url: &str) -> Mime, decice_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.
decice_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,
decice_download: fn(headers: &HeaderMap) -> bool,
) -> Self
pub async fn new_checked( markdown: &'a str, guess_mime_type: fn(url: &str) -> Mime, decice_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.
decice_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)