From b33bb7aa9d1aef677584de75fc562a2a9c292114 Mon Sep 17 00:00:00 2001 From: xenofem Date: Sat, 30 Apr 2022 16:10:12 -0400 Subject: [PATCH] cleanup all the `::Context`s --- src/upload.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/upload.rs b/src/upload.rs index 2c0c219..9357648 100644 --- a/src/upload.rs +++ b/src/upload.rs @@ -82,6 +82,8 @@ impl Actor for Uploader { type Context = ws::WebsocketContext; } +type Context = ::Context; + pub struct UploadedFile { pub name: String, pub size: u64, @@ -141,7 +143,7 @@ impl From<&Error> for ServerMessage { } } -fn stop_and_flush(_: T, u: &mut Uploader, ctx: &mut ::Context) { +fn stop_and_flush(_: T, u: &mut Uploader, ctx: &mut Context) { ctx.stop(); if let Some(w) = u.writer.as_mut() { if let Err(e) = w.flush() { @@ -178,12 +180,12 @@ impl StreamHandler> for Uploader { } } -fn ack(ctx: &mut ::Context) { +fn ack(ctx: &mut Context) { ctx.text("ack"); } impl Uploader { - fn notify_error_and_cleanup(&mut self, e: Error, ctx: &mut ::Context) { + fn notify_error_and_cleanup(&mut self, e: Error, ctx: &mut Context) { error!("{}", e); ctx.text(serde_json::to_string(&ServerMessage::from(&e)).unwrap()); ctx.close(Some(ws::CloseReason { @@ -196,7 +198,7 @@ impl Uploader { fn handle_message( &mut self, msg: ws::Message, - ctx: &mut ::Context, + ctx: &mut Context, ) -> Result { trace!("Websocket message: {:?}", msg); match msg { @@ -273,7 +275,7 @@ impl Uploader { .await .add_file(storage_filename, stored_file) .await - }).map(|res, u: &mut Self, ctx: &mut ::Context| { + }).map(|res, u: &mut Self, ctx: &mut Context| { match res { Ok(Ok(())) => ctx.text(serde_json::to_string(&ServerMessage::Ready { code: u.storage_filename.clone() }).unwrap()), Ok(Err(size)) => u.notify_error_and_cleanup(Error::TooBig(size), ctx), @@ -322,7 +324,7 @@ impl Uploader { } } - fn cleanup_after_error(&mut self, ctx: &mut ::Context) { + fn cleanup_after_error(&mut self, ctx: &mut Context) { info!( "Cleaning up after failed upload of {}", self.storage_filename