January 2019
Intermediate to advanced
520 pages
14h 32m
English
We implement the Handler of the Resize message for ResizeActor, but use the body of the convert function with fields of the passed message:
impl Handler<Resize> for ResizeActor { type Result = ImageResult<Buffer>; fn handle(&mut self, data: Resize, _: &mut SyncContext<Self>) -> Self::Result { let format = image::guess_format(&data.buffer)?; let img = image::load_from_memory(&data.buffer)?; let scaled = img.resize(data.width as u32, data.height as u32, FilterType::Lanczos3); let mut result = Vec::new(); scaled.write_to(&mut result, format)?; Ok(result) } }
We also use SyncContext instead of Context, like we did for previous actors.
All actors are ready and you need to add all modules to the src/actors/mod.rs file:
pub mod count;
Read now
Unlock full access