mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-25 12:33:33 +00:00
Sans IO dispatch
This commit is contained in:
parent
1962369806
commit
b518fd0ef9
2 changed files with 4 additions and 11 deletions
|
@ -10,7 +10,7 @@ use drop_bomb::DropBomb;
|
|||
use ::{
|
||||
Result,
|
||||
req::{ClientRequest, Notification},
|
||||
io::{Io, RawMsg, RawResponse, RawRequest, RawNotification},
|
||||
io::{RawResponse, RawRequest, RawNotification},
|
||||
};
|
||||
|
||||
pub struct Responder<R: ClientRequest> {
|
||||
|
@ -113,9 +113,9 @@ pub fn send_notification<N>(params: N::Params) -> RawNotification
|
|||
}
|
||||
}
|
||||
|
||||
pub fn unknown_method(id: u64) -> Result<RawResponse> {
|
||||
error_response(id, ErrorCode::MethodNotFound, "unknown method")
|
||||
|
||||
pub fn unknown_method(io: &mut Io, raw: RawRequest) -> Result<()> {
|
||||
error(io, raw.id, ErrorCode::MethodNotFound, "unknown method")
|
||||
}
|
||||
|
||||
fn error_response(id: u64, code: ErrorCode, message: &'static str) -> Result<RawResponse> {
|
||||
|
@ -135,13 +135,6 @@ fn error_response(id: u64, code: ErrorCode, message: &'static str) -> Result<Raw
|
|||
Ok(resp)
|
||||
}
|
||||
|
||||
fn error(io: &mut Io, id: u64, code: ErrorCode, message: &'static str) -> Result<()> {
|
||||
let resp = error_response(id, code, message)?;
|
||||
io.send(RawMsg::Response(resp));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
#[allow(unused)]
|
||||
enum ErrorCode {
|
||||
ParseError = -32700,
|
||||
|
|
|
@ -102,7 +102,7 @@ fn on_msg(
|
|||
}
|
||||
if let Some(req) = req {
|
||||
error!("unknown method: {:?}", req);
|
||||
dispatch::unknown_method(io, req)?;
|
||||
io.send(RawMsg::Response(dispatch::unknown_method(req.id)?));
|
||||
}
|
||||
}
|
||||
RawMsg::Notification(not) => {
|
||||
|
|
Loading…
Reference in a new issue