Skip to content

Commit 41dade9

Browse files
committed
return error on combination of bidirectional message and json framing
1 parent 9b03499 commit 41dade9

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

crates/proc-macro-api/src/bidirectional_protocol.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use crate::{
2222
},
2323
},
2424
process::ProcMacroServerProcess,
25-
transport::codec::{json::JsonProtocol, postcard::PostcardProtocol},
25+
transport::codec::postcard::PostcardProtocol,
2626
version,
2727
};
2828

@@ -210,14 +210,16 @@ fn run_request(
210210
msg: BidirectionalMessage,
211211
callback: SubCallback<'_>,
212212
) -> Result<BidirectionalMessage, ServerError> {
213-
if let Some(server_error) = srv.exited() {
214-
return Err(server_error.clone());
213+
if let Some(err) = srv.exited() {
214+
return Err(err.clone());
215215
}
216216

217-
if srv.use_postcard() {
218-
srv.run_bidirectional::<PostcardProtocol>(msg, callback)
219-
} else {
220-
srv.run_bidirectional::<JsonProtocol>(msg, callback)
217+
match srv.use_postcard() {
218+
true => srv.run_bidirectional::<PostcardProtocol>(msg, callback),
219+
false => Err(ServerError {
220+
message: "bidirectional messaging does not support JSON".to_owned(),
221+
io: None,
222+
}),
221223
}
222224
}
223225

0 commit comments

Comments
 (0)