this repo has no description
3
fork

Configure Feed

Select the types of activity you want to include in your feed.

🥅 Don't unwrap results in render_frames engine loop

authored by

Gwenn Le Bihan and committed by
Gwenn Le Bihan
dfc6a38c d255fbda

+14 -16
+14 -16
src/video/encoding.rs
··· 1 - 2 1 use super::{context::Context, engine::milliseconds_to_timestamp, Video}; 3 2 use crate::rendering::stringify_svg; 4 3 use crate::{Canvas, SVGRenderable}; ··· 109 108 .trim_start_matches(&command.name) 110 109 .trim() 111 110 .to_string(); 112 - (command.action)(args, &mut canvas, &mut context) 113 - .unwrap(); 111 + (command.action)(args, &mut canvas, &mut context)?; 114 112 } 115 113 } 116 114 } ··· 122 120 123 121 for (i, hook) in context.later_hooks.iter().enumerate() { 124 122 if (hook.when)(&canvas, &context, previous_rendered_beat) { 125 - (hook.render_function)(&mut canvas, context.ms).unwrap(); 123 + (hook.render_function)(&mut canvas, context.ms)?; 126 124 if hook.once { 127 125 later_hooks_to_delete.push(i); 128 126 } ··· 144 142 previous_rendered_beat, 145 143 previous_rendered_frame, 146 144 ) { 147 - (hook.render_function)(&mut canvas, &mut context).unwrap(); 145 + (hook.render_function)(&mut canvas, &mut context)?; 148 146 } 149 147 } 150 148 151 149 if context.frame != previous_rendered_frame { 152 150 output.send(( 153 151 Duration::from_millis(context.ms as _), 154 - stringify_svg( 155 - canvas 156 - .render_to_svg( 157 - canvas.colormap.clone(), 158 - canvas.cell_size, 159 - canvas.object_sizes, 160 - "", 161 - ) 162 - .unwrap(), 163 - ), 152 + stringify_svg(canvas.render_to_svg( 153 + canvas.colormap.clone(), 154 + canvas.cell_size, 155 + canvas.object_sizes, 156 + "", 157 + )?), 164 158 ))?; 165 159 166 160 written_frames_count += 1; ··· 184 178 std::fs::remove_file(&output_file)?; 185 179 } 186 180 187 - create_dir_all(&output_file.parent().unwrap())?; 181 + create_dir_all( 182 + &output_file 183 + .parent() 184 + .expect("Given output file has no parent"), 185 + )?; 188 186 189 187 let mut encoder = self.setup_encoder(&output_file)?; 190 188