Bizarre hack that seems to fix the type_length_limit error, but I'm not sure why

This commit is contained in:
Tangent Wantwight 2020-05-25 23:24:55 -04:00
parent 319f082d53
commit 48ab9547ed
2 changed files with 7 additions and 8 deletions

View file

@ -1,5 +1,3 @@
// TODO: try doing without this every now and then, hopefully it's eventually unnecessary
#![type_length_limit="1272053"]
#[macro_use] #[macro_use]
extern crate log; extern crate log;
@ -59,7 +57,7 @@ async fn main() -> Result<()> {
async fn handle_socket(websocket: WebSocket) -> Result<()> { async fn handle_socket(websocket: WebSocket) -> Result<()> {
let (sink, source) = websocket.split(); let (sink, source) = websocket.split();
let sink = sink.with(|msg: ServerMessage| { let mut sink = sink.with(|msg: ServerMessage| {
ready( ready(
to_string(&msg) to_string(&msg)
.context("JSON encoding shouldn't fail") .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() { ready(match msg.to_str() {
Ok(json) => from_str::<ClientMessage>(json) Ok(json) => from_str::<ClientMessage>(json)
.context("Parsing 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
} }

View file

@ -25,11 +25,12 @@ where
.context("Greeting client") .context("Greeting client")
} }
pub async fn run_client<I, O>(mut source: I, mut sink: O) -> Result<()>
where where
I: Stream<Item = Result<ClientMessage, Error>> + Unpin,
O: Sink<ServerMessage, Error = Error> + Unpin,
{ {
pub async fn run_client(
source: &mut (impl Stream<Item = Result<ClientMessage, Error>> + Send + Unpin),
mut sink: &mut (impl Sink<ServerMessage, Error = Error> + Send + Unpin),
) -> Result<()> {
let output_task = async { let output_task = async {
greet(&mut sink).await?; greet(&mut sink).await?;
Ok::<(), Error>(()) Ok::<(), Error>(())