dispatch_buf

This commit is contained in:
NikVolf 2016-04-03 23:39:49 +03:00
parent 0a60da622f
commit b04d8196c7
3 changed files with 36 additions and 1 deletions

View File

@ -531,6 +531,15 @@ fn implement_interface(
_ => vec![]
}
}
fn dispatch_buf<R>(&self, method_num: u16, r: &mut R) -> Vec<u8>
where R: ::std::io::Read
{
match method_num {
$dispatch_arms
_ => vec![]
}
}
}
).unwrap(), dispatch_table))
}

View File

@ -14,7 +14,29 @@
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
//! Ethcore implementation of IPC over nanomsg transport
//! IPC over nanomsg transport
extern crate ethcore_ipc as ipc;
extern crate nanomsg;
pub use ipc::*;
use std::sync::*;
use nanomsg::{Socket, Protocol};
pub struct Worker<S> where S: IpcInterface<S> {
service: Arc<S>,
sockets: Vec<Socket>,
}
impl<S> Worker<S> where S: IpcInterface<S> {
pub fn new(service: Arc<S>, socket_addr: &str) -> Worker<S> {
Worker::<S> {
service: service.clone(),
sockets: Vec::new(),
}
}
pub fn work_loop(&mut self) {
}
}

View File

@ -23,6 +23,10 @@ use std::sync::atomic::*;
pub trait IpcInterface<T> {
/// reads the message from io, dispatches the call and returns result
fn dispatch<R>(&self, r: &mut R) -> Vec<u8> where R: Read;
/// deserialize the payload from the io `r` and invokes method specified by `method_num`
/// (for non-blocking io)
fn dispatch_buf<R>(&self, method_num: u16, r: &mut R) -> Vec<u8> where R: Read;
}
/// serializes method invocation (method_num and parameters) to the stream specified by `w`