got rid of the generic parameter for ipc interface
This commit is contained in:
parent
77bbab009e
commit
c3ef5c10a3
@ -43,4 +43,4 @@ pub trait ChainNotify : Send + Sync {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl IpcConfig<ChainNotify> for ChainNotify { }
|
impl IpcConfig for ChainNotify { }
|
||||||
|
@ -1015,4 +1015,4 @@ impl MayPanic for Client {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl IpcConfig<BlockChainClient> for BlockChainClient { }
|
impl IpcConfig for BlockChainClient { }
|
||||||
|
@ -768,7 +768,7 @@ fn ty_ident_map(original_ty: &P<Ty>) -> IdentMap {
|
|||||||
ident_map
|
ident_map
|
||||||
}
|
}
|
||||||
|
|
||||||
/// implements `IpcInterface<C>` for the given class `C`
|
/// implements `IpcInterface` for the given class `C`
|
||||||
fn implement_interface(
|
fn implement_interface(
|
||||||
cx: &ExtCtxt,
|
cx: &ExtCtxt,
|
||||||
builder: &aster::AstBuilder,
|
builder: &aster::AstBuilder,
|
||||||
@ -834,7 +834,7 @@ fn implement_interface(
|
|||||||
};
|
};
|
||||||
|
|
||||||
let ipc_item = quote_item!(cx,
|
let ipc_item = quote_item!(cx,
|
||||||
impl $host_generics ::ipc::IpcInterface<$interface_endpoint> for $interface_endpoint $where_clause {
|
impl $host_generics ::ipc::IpcInterface for $interface_endpoint $where_clause {
|
||||||
fn dispatch<R>(&self, r: &mut R) -> Vec<u8>
|
fn dispatch<R>(&self, r: &mut R) -> Vec<u8>
|
||||||
where R: ::std::io::Read
|
where R: ::std::io::Read
|
||||||
{
|
{
|
||||||
|
@ -75,4 +75,4 @@ impl HypervisorService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ::ipc::IpcConfig<HypervisorService> for HypervisorService {}
|
impl ::ipc::IpcConfig for HypervisorService {}
|
||||||
|
@ -33,7 +33,7 @@ const POLL_TIMEOUT: isize = 100;
|
|||||||
const CLIENT_CONNECTION_TIMEOUT: isize = 2500;
|
const CLIENT_CONNECTION_TIMEOUT: isize = 2500;
|
||||||
|
|
||||||
/// Generic worker to handle service (binded) sockets
|
/// Generic worker to handle service (binded) sockets
|
||||||
pub struct Worker<S: ?Sized> where S: IpcInterface<S> {
|
pub struct Worker<S: ?Sized> where S: IpcInterface {
|
||||||
service: Arc<S>,
|
service: Arc<S>,
|
||||||
sockets: Vec<(Socket, Endpoint)>,
|
sockets: Vec<(Socket, Endpoint)>,
|
||||||
polls: Vec<PollFd>,
|
polls: Vec<PollFd>,
|
||||||
@ -54,9 +54,9 @@ impl<S> GuardedSocket<S> where S: WithSocket<Socket> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<S> Deref for GuardedSocket<S> where S: WithSocket<Socket> {
|
impl<S> Deref for GuardedSocket<S> where S: WithSocket<Socket> {
|
||||||
type Target = Arc<S>;
|
type Target = S;
|
||||||
|
|
||||||
fn deref(&self) -> &Arc<S> {
|
fn deref(&self) -> &S {
|
||||||
&self.client
|
&self.client
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -116,7 +116,7 @@ pub enum SocketError {
|
|||||||
RequestLink,
|
RequestLink,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: ?Sized> Worker<S> where S: IpcInterface<S> {
|
impl<S: ?Sized> Worker<S> where S: IpcInterface {
|
||||||
/// New worker over specified `service`
|
/// New worker over specified `service`
|
||||||
pub fn new(service: &Arc<S>) -> Worker<S> {
|
pub fn new(service: &Arc<S>) -> Worker<S> {
|
||||||
Worker::<S> {
|
Worker::<S> {
|
||||||
|
@ -29,7 +29,7 @@ pub struct Handshake {
|
|||||||
|
|
||||||
/// Allows to configure custom version and custom handshake response for
|
/// Allows to configure custom version and custom handshake response for
|
||||||
/// ipc host
|
/// ipc host
|
||||||
pub trait IpcConfig<I: ?Sized> {
|
pub trait IpcConfig {
|
||||||
/// Current service api version
|
/// Current service api version
|
||||||
/// Should be increased if any of the methods changes signature
|
/// Should be increased if any of the methods changes signature
|
||||||
fn api_version() -> Version {
|
fn api_version() -> Version {
|
||||||
@ -60,7 +60,7 @@ pub enum Error {
|
|||||||
|
|
||||||
/// Allows implementor to be attached to generic worker and dispatch rpc requests
|
/// Allows implementor to be attached to generic worker and dispatch rpc requests
|
||||||
/// over IPC
|
/// over IPC
|
||||||
pub trait IpcInterface<I :?Sized> : IpcConfig<I> {
|
pub trait IpcInterface : 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;
|
||||||
|
|
||||||
|
@ -92,7 +92,7 @@ impl Args {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run_service<T: ?Sized + Send + Sync + 'static>(addr: &str, stop_guard: Arc<AtomicBool>, service: Arc<T>) where T: IpcInterface<T> {
|
fn run_service<T: ?Sized + Send + Sync + 'static>(addr: &str, stop_guard: Arc<AtomicBool>, service: Arc<T>) where T: IpcInterface {
|
||||||
let socket_url = addr.to_owned();
|
let socket_url = addr.to_owned();
|
||||||
std::thread::spawn(move || {
|
std::thread::spawn(move || {
|
||||||
let mut worker = nanoipc::Worker::<T>::new(&service);
|
let mut worker = nanoipc::Worker::<T>::new(&service);
|
||||||
@ -114,7 +114,7 @@ fn main() {
|
|||||||
remote_client.handshake().unwrap();
|
remote_client.handshake().unwrap();
|
||||||
|
|
||||||
let stop = Arc::new(AtomicBool::new(false));
|
let stop = Arc::new(AtomicBool::new(false));
|
||||||
let sync = EthSync::new(sync_config, remote_client.clone(), network_config).unwrap();
|
let sync = EthSync::new(sync_config, remote_client.service().clone(), network_config).unwrap();
|
||||||
|
|
||||||
run_service("ipc:///tmp/parity-sync.ipc", stop.clone(), sync.clone() as Arc<SyncProvider>);
|
run_service("ipc:///tmp/parity-sync.ipc", stop.clone(), sync.clone() as Arc<SyncProvider>);
|
||||||
run_service("ipc:///tmp/parity-manage-net.ipc", stop.clone(), sync.clone() as Arc<ManageNetwork>);
|
run_service("ipc:///tmp/parity-manage-net.ipc", stop.clone(), sync.clone() as Arc<ManageNetwork>);
|
||||||
|
@ -149,8 +149,8 @@ impl ChainNotify for EthSync {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl IpcConfig<ManageNetwork> for ManageNetwork { }
|
impl IpcConfig for ManageNetwork { }
|
||||||
impl IpcConfig<SyncProvider> for SyncProvider { }
|
impl IpcConfig for SyncProvider { }
|
||||||
|
|
||||||
/// Trait for managing network
|
/// Trait for managing network
|
||||||
pub trait ManageNetwork : Send + Sync {
|
pub trait ManageNetwork : Send + Sync {
|
||||||
|
Loading…
Reference in New Issue
Block a user