From 48ab9547ed338c243835643f84afc6d5f7a8546b Mon Sep 17 00:00:00 2001 From: Tangent Wantwight Date: Mon, 25 May 2020 23:24:55 -0400 Subject: [PATCH] Bizarre hack that seems to fix the type_length_limit error, but I'm not sure why --- src/main.rs | 8 +++----- src/net/server.rs | 7 ++++--- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/main.rs b/src/main.rs index 0ff6d44..7508c47 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,3 @@ -// TODO: try doing without this every now and then, hopefully it's eventually unnecessary -#![type_length_limit="1272053"] #[macro_use] extern crate log; @@ -59,7 +57,7 @@ async fn main() -> Result<()> { async fn handle_socket(websocket: WebSocket) -> Result<()> { let (sink, source) = websocket.split(); - let sink = sink.with(|msg: ServerMessage| { + let mut sink = sink.with(|msg: ServerMessage| { ready( to_string(&msg) .context("JSON encoding shouldn't fail") @@ -67,7 +65,7 @@ async fn handle_socket(websocket: WebSocket) -> Result<()> { ) }); - let source = source.map_err(Into::into).try_filter_map(|msg| { + let mut source = source.map_err(Into::into).try_filter_map(|msg| { ready(match msg.to_str() { Ok(json) => from_str::(json) .context("Parsing JSON") @@ -79,5 +77,5 @@ async fn handle_socket(websocket: WebSocket) -> Result<()> { }) }); - run_client(source, sink).await + run_client(&mut source, &mut sink).await } diff --git a/src/net/server.rs b/src/net/server.rs index 4f048db..d53cac6 100644 --- a/src/net/server.rs +++ b/src/net/server.rs @@ -25,11 +25,12 @@ where .context("Greeting client") } -pub async fn run_client(mut source: I, mut sink: O) -> Result<()> where - I: Stream> + Unpin, - O: Sink + Unpin, { +pub async fn run_client( + source: &mut (impl Stream> + Send + Unpin), + mut sink: &mut (impl Sink + Send + Unpin), +) -> Result<()> { let output_task = async { greet(&mut sink).await?; Ok::<(), Error>(())