got rid of the generic parameter for ipc interface

This commit is contained in:
NikVolf 2016-07-16 19:24:45 +02:00
parent 77bbab009e
commit c3ef5c10a3
8 changed files with 15 additions and 15 deletions

View File

@ -43,4 +43,4 @@ pub trait ChainNotify : Send + Sync {
}
}
impl IpcConfig<ChainNotify> for ChainNotify { }
impl IpcConfig for ChainNotify { }

View File

@ -1015,4 +1015,4 @@ impl MayPanic for Client {
}
}
impl IpcConfig<BlockChainClient> for BlockChainClient { }
impl IpcConfig for BlockChainClient { }

View File

@ -768,7 +768,7 @@ fn ty_ident_map(original_ty: &P<Ty>) -> IdentMap {
ident_map
}
/// implements `IpcInterface<C>` for the given class `C`
/// implements `IpcInterface` for the given class `C`
fn implement_interface(
cx: &ExtCtxt,
builder: &aster::AstBuilder,
@ -834,7 +834,7 @@ fn implement_interface(
};
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>
where R: ::std::io::Read
{

View File

@ -75,4 +75,4 @@ impl HypervisorService {
}
}
impl ::ipc::IpcConfig<HypervisorService> for HypervisorService {}
impl ::ipc::IpcConfig for HypervisorService {}

View File

@ -33,7 +33,7 @@ const POLL_TIMEOUT: isize = 100;
const CLIENT_CONNECTION_TIMEOUT: isize = 2500;
/// 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>,
sockets: Vec<(Socket, Endpoint)>,
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> {
type Target = Arc<S>;
type Target = S;
fn deref(&self) -> &Arc<S> {
fn deref(&self) -> &S {
&self.client
}
}
@ -116,7 +116,7 @@ pub enum SocketError {
RequestLink,
}
impl<S: ?Sized> Worker<S> where S: IpcInterface<S> {
impl<S: ?Sized> Worker<S> where S: IpcInterface {
/// New worker over specified `service`
pub fn new(service: &Arc<S>) -> Worker<S> {
Worker::<S> {

View File

@ -29,7 +29,7 @@ pub struct Handshake {
/// Allows to configure custom version and custom handshake response for
/// ipc host
pub trait IpcConfig<I: ?Sized> {
pub trait IpcConfig {
/// Current service api version
/// Should be increased if any of the methods changes signature
fn api_version() -> Version {
@ -60,7 +60,7 @@ pub enum Error {
/// Allows implementor to be attached to generic worker and dispatch rpc requests
/// 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
fn dispatch<R>(&self, r: &mut R) -> Vec<u8> where R: Read;

View File

@ -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();
std::thread::spawn(move || {
let mut worker = nanoipc::Worker::<T>::new(&service);
@ -114,7 +114,7 @@ fn main() {
remote_client.handshake().unwrap();
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-manage-net.ipc", stop.clone(), sync.clone() as Arc<ManageNetwork>);

View File

@ -149,8 +149,8 @@ impl ChainNotify for EthSync {
}
}
impl IpcConfig<ManageNetwork> for ManageNetwork { }
impl IpcConfig<SyncProvider> for SyncProvider { }
impl IpcConfig for ManageNetwork { }
impl IpcConfig for SyncProvider { }
/// Trait for managing network
pub trait ManageNetwork : Send + Sync {