client spawner

This commit is contained in:
NikVolf
2016-04-12 10:18:39 +03:00
parent 5609b555d2
commit 40e0d370c2
8 changed files with 72 additions and 16 deletions

View File

@@ -9,3 +9,4 @@ license = "GPL-3.0"
[dependencies]
ethcore-devtools = { path = "../../devtools" }
semver = "0.2.0"
nanomsg = "0.5.0"

View File

@@ -18,7 +18,6 @@
use std::io::{Read, Write};
use std::marker::Sync;
use std::sync::atomic::*;
use semver::Version;
pub struct Handshake {
@@ -47,7 +46,7 @@ pub enum Error {
HandshakeFailed,
}
pub trait IpcInterface<T> where T: IpcConfig {
pub trait IpcInterface<T>:IpcConfig {
/// reads the message from io, dispatches the call and returns serialized result
fn dispatch<R>(&self, r: &mut R) -> Vec<u8> where R: Read;
@@ -81,5 +80,12 @@ pub fn invoke<W>(method_num: u16, params: &Option<Vec<u8>>, w: &mut W) where W:
pub trait IpcSocket: Read + Write + Sync {
}
impl IpcSocket for ::devtools::TestSocket {
pub trait WithSocket<S: IpcSocket> {
fn init(socket: S) -> Self;
}
impl IpcSocket for ::devtools::TestSocket {}
impl IpcSocket for ::nanomsg::Socket {}

View File

@@ -18,6 +18,7 @@
extern crate ethcore_devtools as devtools;
extern crate semver;
extern crate nanomsg;
pub mod interface;
pub use interface::{IpcInterface, IpcSocket, invoke, IpcConfig, Handshake, Error};
pub use interface::{IpcInterface, IpcSocket, invoke, IpcConfig, Handshake, Error, WithSocket};