adding ron to slide serializing...

It's possible I could use this as a method of creating slides in text
form. It's vastly easier to implement.
This commit is contained in:
Chris Cochrun 2024-11-11 12:02:42 -06:00
parent 66c37775d1
commit 2408404ff4
5 changed files with 68 additions and 19 deletions

1
Cargo.lock generated
View file

@ -3132,6 +3132,7 @@ dependencies = [
"libcosmic", "libcosmic",
"miette", "miette",
"pretty_assertions", "pretty_assertions",
"ron",
"serde", "serde",
"serde-lexpr", "serde-lexpr",
"strum", "strum",

View file

@ -19,3 +19,4 @@ tracing-subscriber = { version = "0.3.18", features = ["fmt", "std", "chrono", "
iced_video_player = { git = "https://github.com/jackpot51/iced_video_player", branch = "cosmic", features = ["wgpu"] } iced_video_player = { git = "https://github.com/jackpot51/iced_video_player", branch = "cosmic", features = ["wgpu"] }
strum = "0.26.3" strum = "0.26.3"
strum_macros = "0.26.4" strum_macros = "0.26.4"
ron = "0.8.1"

View file

@ -27,9 +27,10 @@ pub(crate) enum Keyword {
ImageFit(ImageFit), ImageFit(ImageFit),
} }
#[derive(Debug, Clone, PartialEq, Eq, EnumString)] #[derive(Debug, Default, Clone, PartialEq, Eq, EnumString)]
pub(crate) enum ImageFit { pub(crate) enum ImageFit {
#[strum(ascii_case_insensitive)] #[strum(ascii_case_insensitive)]
#[default]
Cover, Cover,
#[strum(ascii_case_insensitive)] #[strum(ascii_case_insensitive)]
Fill, Fill,

View file

@ -316,25 +316,25 @@ fn build_image_bg(atom: &Value, image_map: &mut HashMap<String, String>, map_ind
} }
} }
fn build_slide(exp: Value) -> Result<Slide> { // fn build_slide(exp: Value) -> Result<Slide> {
let mut slide_builder = SlideBuilder::new(); // let mut slide_builder = SlideBuilder::new();
let mut keyword = "idk"; // let mut keyword = "idk";
for value in exp.as_cons().unwrap().to_vec().0 { // for value in exp.as_cons().unwrap().to_vec().0 {
let mut vecs = vec![vec![]]; // let mut vecs = vec![vec![]];
match value { // match value {
Value::Symbol(symbol) => {} // Value::Symbol(symbol) => {}
Value::Keyword(keyword) => {} // Value::Keyword(keyword) => {}
Value::String(string) => {} // Value::String(string) => {}
Value::Number(num) => {} // Value::Number(num) => {}
Value::Cons(cons) => { // Value::Cons(cons) => {
vecs.push(get_lists(&value)); // vecs.push(get_lists(&value));
} // }
_ => {} // _ => {}
} // }
} // }
todo!() // todo!()
} // }
fn build_slides( fn build_slides(
cons: &lexpr::Cons, cons: &lexpr::Cons,
@ -429,4 +429,19 @@ mod test {
let test_slide = test_slide(); let test_slide = test_slide();
assert_eq!(slide, test_slide) assert_eq!(slide, test_slide)
} }
#[test]
fn test_ron_deserialize() {
let slide = read_to_string("./test_presentation.ron").expect("Problem getting file read");
match ron::from_str::<Vec<Slide>>(&slide) {
Ok(s) => {
dbg!(s);
assert!(true)
}
Err(e) => {
dbg!(e);
assert!(false)
}
}
}
} }

31
test_presentation.ron Normal file
View file

@ -0,0 +1,31 @@
[
(
id: 0,
background: Background(
path: "~/pics/frodo.jpg",
kind: Image
),
text: "This is Frodo",
font: "Quicksand",
font_size: 50,
text_alignment: MiddleCenter,
video_loop: false,
video_start_time: 0.0,
video_end_time: 0.0,
),
(
id: 0,
background: Background(
path: "~/vids/test/chosensmol.mp4",
kind: Video
),
text: "This is Frodo",
font: "Quicksand",
font_size: 50,
text_alignment: MiddleCenter,
video_loop: false,
video_start_time: 0.0,
video_end_time: 0.0,
)
]