Bizarre hack that seems to fix the type_length_limit error, but I'm not sure why
This commit is contained in:
parent
319f082d53
commit
48ab9547ed
2 changed files with 7 additions and 8 deletions
|
@ -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::<ClientMessage>(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
|
||||
}
|
||||
|
|
|
@ -25,11 +25,12 @@ where
|
|||
.context("Greeting client")
|
||||
}
|
||||
|
||||
pub async fn run_client<I, O>(mut source: I, mut sink: O) -> Result<()>
|
||||
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 {
|
||||
greet(&mut sink).await?;
|
||||
Ok::<(), Error>(())
|
||||
|
|
Loading…
Reference in a new issue