ipcconfig trait
This commit is contained in:
parent
46a25b31ab
commit
72acd67644
@ -36,6 +36,8 @@ use syntax::ptr::P;
|
|||||||
|
|
||||||
pub struct Error;
|
pub struct Error;
|
||||||
|
|
||||||
|
const RESERVED_MESSAGE_IDS: u16 = 16;
|
||||||
|
|
||||||
pub fn expand_ipc_implementation(
|
pub fn expand_ipc_implementation(
|
||||||
cx: &mut ExtCtxt,
|
cx: &mut ExtCtxt,
|
||||||
span: Span,
|
span: Span,
|
||||||
|
@ -8,3 +8,4 @@ license = "GPL-3.0"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
ethcore-devtools = { path = "../../devtools" }
|
ethcore-devtools = { path = "../../devtools" }
|
||||||
|
semver = "0.2.0"
|
||||||
|
@ -19,8 +19,24 @@
|
|||||||
use std::io::{Read, Write};
|
use std::io::{Read, Write};
|
||||||
use std::marker::Sync;
|
use std::marker::Sync;
|
||||||
use std::sync::atomic::*;
|
use std::sync::atomic::*;
|
||||||
|
use semver::Version;
|
||||||
|
|
||||||
pub trait IpcInterface<T> {
|
pub struct Handshake {
|
||||||
|
protocol_version: Version,
|
||||||
|
api_version: Version,
|
||||||
|
reserved: [u8; 64],
|
||||||
|
}
|
||||||
|
|
||||||
|
pub trait IpcConfig {
|
||||||
|
fn api_version() -> Version {
|
||||||
|
Version::parse("1.0.0").unwrap()
|
||||||
|
}
|
||||||
|
fn protocol_version() -> Version {
|
||||||
|
Version::parse("1.0.0").unwrap()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub trait IpcInterface<T> where T: IpcConfig {
|
||||||
/// reads the message from io, dispatches the call and returns serialized result
|
/// reads the message from io, dispatches the call and returns serialized result
|
||||||
fn dispatch<R>(&self, r: &mut R) -> Vec<u8> where R: Read;
|
fn dispatch<R>(&self, r: &mut R) -> Vec<u8> where R: Read;
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
//! IPC RPC interface
|
//! IPC RPC interface
|
||||||
|
|
||||||
extern crate ethcore_devtools as devtools;
|
extern crate ethcore_devtools as devtools;
|
||||||
|
extern crate semver;
|
||||||
|
|
||||||
pub mod interface;
|
pub mod interface;
|
||||||
pub use interface::{IpcInterface, IpcSocket, invoke};
|
pub use interface::{IpcInterface, IpcSocket, invoke, IpcConfig};
|
||||||
|
@ -12,6 +12,7 @@ path = "run.rs"
|
|||||||
bincode = "*"
|
bincode = "*"
|
||||||
serde = "0.7.0"
|
serde = "0.7.0"
|
||||||
ethcore-devtools = { path = "../../devtools" }
|
ethcore-devtools = { path = "../../devtools" }
|
||||||
|
semver = "0.2.0"
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
syntex = "0.30.0"
|
syntex = "0.30.0"
|
||||||
|
@ -20,6 +20,7 @@ mod tests {
|
|||||||
use super::super::service::*;
|
use super::super::service::*;
|
||||||
use ipc::*;
|
use ipc::*;
|
||||||
use devtools::*;
|
use devtools::*;
|
||||||
|
use semver::Version;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn call_service() {
|
fn call_service() {
|
||||||
@ -57,4 +58,12 @@ mod tests {
|
|||||||
assert_eq!(vec![0, 1, 1, 0, 0, 0, 5, 0, 0, 0, 10], service_client.socket().borrow().write_buffer.clone());
|
assert_eq!(vec![0, 1, 1, 0, 0, 0, 5, 0, 0, 0, 10], service_client.socket().borrow().write_buffer.clone());
|
||||||
assert_eq!(10, result);
|
assert_eq!(10, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn query_default_version() {
|
||||||
|
let ver = Service::protocol_version();
|
||||||
|
assert_eq!(ver, Version::parse("1.0.0").unwrap());
|
||||||
|
let ver = Service::api_version();
|
||||||
|
assert_eq!(ver, Version::parse("1.0.0").unwrap());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@ extern crate bincode;
|
|||||||
extern crate ethcore_ipc as ipc;
|
extern crate ethcore_ipc as ipc;
|
||||||
extern crate serde;
|
extern crate serde;
|
||||||
extern crate ethcore_devtools as devtools;
|
extern crate ethcore_devtools as devtools;
|
||||||
|
extern crate semver;
|
||||||
|
|
||||||
pub mod service;
|
pub mod service;
|
||||||
mod examples;
|
mod examples;
|
||||||
|
@ -45,3 +45,5 @@ impl Service {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl ::ipc::IpcConfig for Service {}
|
||||||
|
Loading…
Reference in New Issue
Block a user