diff --git a/src/core/slide.rs b/src/core/slide.rs index f71225b..662710a 100644 --- a/src/core/slide.rs +++ b/src/core/slide.rs @@ -236,6 +236,26 @@ impl From<&Slide> for Value { } impl Slide { + pub fn set_text(mut self, text: impl AsRef) -> Self { + self.text = text.as_ref().into(); + self + } + + pub fn set_font(mut self, font: impl AsRef) -> Self { + self.font = font.as_ref().into(); + self + } + + pub fn set_font_size(mut self, font_size: i32) -> Self { + self.font_size = font_size; + self + } + + pub fn set_audio(mut self, audio: Option) -> Self { + self.audio = audio; + self + } + pub fn background(&self) -> &Background { &self.background } diff --git a/src/lisp.rs b/src/lisp.rs index 28bcc46..e5baa50 100644 --- a/src/lisp.rs +++ b/src/lisp.rs @@ -37,7 +37,10 @@ pub fn parse_lisp(value: Value) -> Vec { #[cfg(test)] mod test { - use std::{fs::read_to_string, path::PathBuf}; + use std::{ + fs::read_to_string, + path::{Path, PathBuf}, + }; use crate::{ core::{ @@ -101,13 +104,19 @@ mod test { fn service_item_1() -> ServiceItem { let image = Image { - title: "frodo.jpg".to_string(), + title: "This is frodo".to_string(), path: PathBuf::from("~/pics/frodo.jpg"), ..Default::default() }; let slide = &image.to_slides().unwrap()[0]; + let slide = slide + .clone() + .set_text("This is frodo") + .set_font("Quicksand") + .set_font_size(70) + .set_audio(None); ServiceItem { - title: "frodo.jpg".to_string(), + title: "This is frodo".to_string(), kind: ServiceItemKind::Content(slide.clone()), ..Default::default() }