use std::path::PathBuf;
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum ImageHandlingMode {
InMarkdown,
Manually,
Save,
}
#[derive(Debug, Clone)]
pub struct ParserConfig {
pub extract_images: bool,
pub compress_images: bool,
pub quality: u8,
pub image_handling_mode: ImageHandlingMode,
pub image_output_path: Option<PathBuf>,
pub include_slide_number_as_comment: bool,
pub include_speaker_notes: bool,
pub include_comments: bool,
pub include_presentation_metadata: bool,
}
impl Default for ParserConfig {
fn default() -> Self {
Self {
extract_images: true,
compress_images: true,
quality: 80,
image_handling_mode: ImageHandlingMode::InMarkdown,
image_output_path: None,
include_slide_number_as_comment: true,
include_speaker_notes: false,
include_comments: false,
include_presentation_metadata: true,
}
}
}
impl ParserConfig {
pub fn builder() -> ParserConfigBuilder {
ParserConfigBuilder::default()
}
}
#[derive(Debug, Default)]
pub struct ParserConfigBuilder {
extract_images: Option<bool>,
compress_images: Option<bool>,
image_quality: Option<u8>,
image_handling_mode: Option<ImageHandlingMode>,
image_output_path: Option<PathBuf>,
include_slide_number_as_comment: Option<bool>,
include_speaker_notes: Option<bool>,
include_comments: Option<bool>,
include_presentation_metadata: Option<bool>,
}
impl ParserConfigBuilder {
pub fn extract_images(mut self, value: bool) -> Self {
self.extract_images = Some(value);
self
}
pub fn compress_images(mut self, value: bool) -> Self {
self.compress_images = Some(value);
self
}
pub fn quality(mut self, value: u8) -> Self {
self.image_quality = Some(value);
self
}
pub fn image_handling_mode(mut self, value: ImageHandlingMode) -> Self {
self.image_handling_mode = Some(value);
self
}
pub fn image_output_path<P>(mut self, path: P) -> Self
where
P: Into<PathBuf>,
{
self.image_output_path = Some(path.into());
self
}
pub fn include_slide_number_as_comment(mut self, value: bool) -> Self {
self.include_slide_number_as_comment = Some(value);
self
}
pub fn include_speaker_notes(mut self, value: bool) -> Self {
self.include_speaker_notes = Some(value);
self
}
pub fn include_comments(mut self, value: bool) -> Self {
self.include_comments = Some(value);
self
}
pub fn include_presentation_metadata(mut self, value: bool) -> Self {
self.include_presentation_metadata = Some(value);
self
}
pub fn build(self) -> ParserConfig {
ParserConfig {
extract_images: self.extract_images.unwrap_or(true),
compress_images: self.compress_images.unwrap_or(true),
quality: self.image_quality.unwrap_or(80),
image_handling_mode: self
.image_handling_mode
.unwrap_or(ImageHandlingMode::InMarkdown),
image_output_path: self.image_output_path,
include_slide_number_as_comment: self.include_slide_number_as_comment.unwrap_or(true),
include_speaker_notes: self.include_speaker_notes.unwrap_or(false),
include_comments: self.include_comments.unwrap_or(false),
include_presentation_metadata: self.include_presentation_metadata.unwrap_or(true),
}
}
}