aboutsummaryrefslogtreecommitdiff
path: root/crates/server/src
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-08-12 20:12:51 +0100
committerAleksey Kladov <[email protected]>2018-08-12 20:12:51 +0100
commitb518fd0ef91d8ca3d9814b335c7be8684d1692a9 (patch)
tree68d00e49fdf18a56afd94ceee792cc1bf151768e /crates/server/src
parent196236980613249f25ccb2968a214922f7db10f1 (diff)
Sans IO dispatch
Diffstat (limited to 'crates/server/src')
-rw-r--r--crates/server/src/dispatch.rs13
-rw-r--r--crates/server/src/main_loop/mod.rs2
2 files changed, 4 insertions, 11 deletions
diff --git a/crates/server/src/dispatch.rs b/crates/server/src/dispatch.rs
index 381649859..bfdbd30ca 100644
--- a/crates/server/src/dispatch.rs
+++ b/crates/server/src/dispatch.rs
@@ -10,7 +10,7 @@ use drop_bomb::DropBomb;
10use ::{ 10use ::{
11 Result, 11 Result,
12 req::{ClientRequest, Notification}, 12 req::{ClientRequest, Notification},
13 io::{Io, RawMsg, RawResponse, RawRequest, RawNotification}, 13 io::{RawResponse, RawRequest, RawNotification},
14}; 14};
15 15
16pub struct Responder<R: ClientRequest> { 16pub struct Responder<R: ClientRequest> {
@@ -113,9 +113,9 @@ pub fn send_notification<N>(params: N::Params) -> RawNotification
113 } 113 }
114} 114}
115 115
116pub fn unknown_method(id: u64) -> Result<RawResponse> {
117 error_response(id, ErrorCode::MethodNotFound, "unknown method")
116 118
117pub fn unknown_method(io: &mut Io, raw: RawRequest) -> Result<()> {
118 error(io, raw.id, ErrorCode::MethodNotFound, "unknown method")
119} 119}
120 120
121fn error_response(id: u64, code: ErrorCode, message: &'static str) -> Result<RawResponse> { 121fn 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
135 Ok(resp) 135 Ok(resp)
136} 136}
137 137
138fn error(io: &mut Io, id: u64, code: ErrorCode, message: &'static str) -> Result<()> {
139 let resp = error_response(id, code, message)?;
140 io.send(RawMsg::Response(resp));
141 Ok(())
142}
143
144
145#[allow(unused)] 138#[allow(unused)]
146enum ErrorCode { 139enum ErrorCode {
147 ParseError = -32700, 140 ParseError = -32700,
diff --git a/crates/server/src/main_loop/mod.rs b/crates/server/src/main_loop/mod.rs
index e7b24e53f..e80b9988d 100644
--- a/crates/server/src/main_loop/mod.rs
+++ b/crates/server/src/main_loop/mod.rs
@@ -102,7 +102,7 @@ fn on_msg(
102 } 102 }
103 if let Some(req) = req { 103 if let Some(req) = req {
104 error!("unknown method: {:?}", req); 104 error!("unknown method: {:?}", req);
105 dispatch::unknown_method(io, req)?; 105 io.send(RawMsg::Response(dispatch::unknown_method(req.id)?));
106 } 106 }
107 } 107 }
108 RawMsg::Notification(not) => { 108 RawMsg::Notification(not) => {