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