diff options
| author | Erik Larkö <erik@mullvad.net> | 2017-02-27 11:20:23 +0800 |
|---|---|---|
| committer | Erik Larkö <erik@mullvad.net> | 2017-03-02 21:29:23 +0800 |
| commit | a8e76d7e36eb111586fa52de33c303c959d02cc9 (patch) | |
| tree | 42341de3ad4edd26949dfacd120f1084413ae4a6 /src/ipc/mod.rs | |
| parent | f720577fb80af171d3672c081297c8686e5d65f2 (diff) | |
| download | mullvadvpn-a8e76d7e36eb111586fa52de33c303c959d02cc9.tar.xz mullvadvpn-a8e76d7e36eb111586fa52de33c303c959d02cc9.zip | |
IPC in separate crate
Diffstat (limited to 'src/ipc/mod.rs')
| -rw-r--r-- | src/ipc/mod.rs | 43 |
1 files changed, 0 insertions, 43 deletions
diff --git a/src/ipc/mod.rs b/src/ipc/mod.rs deleted file mode 100644 index afb140f4c6..0000000000 --- a/src/ipc/mod.rs +++ /dev/null @@ -1,43 +0,0 @@ -#[cfg(windows)] -#[path = "nop_ipc.rs"] -mod ipc_impl; - -#[cfg(not(windows))] -#[path = "zmq_ipc.rs"] -mod ipc_impl; - -pub use self::ipc_impl::*; - -/// The type signature for functions accepting messages from the server. -/// If the server fails in delivering the message for any reason it will -/// put the cause in the Err part of the `Result`. -pub type OnMessage<MessageType> = FnMut(Result<MessageType>) + Send + 'static; - -/// The server end of our Inter-Process Communcation implementation. -pub trait IpcServer { - type MessageType; - - /// Starts listening to incoming IPC connections on the specified port. - /// Messages are sent to the `on_message` callback. If anything went wrong - /// when reading or parsing the message, the message will be an `Err`. - /// NOTE that this does not apply to errors regarding whether the server - /// could start or not, those are returned directly by this function. - /// - /// This function is non-blocking and thus spawns a thread where it - /// listens to messages. - fn start(self, port: u16, on_message: Box<OnMessage<Self::MessageType>>) -> Result<()>; -} - -error_chain!{ - errors { - ReadFailure { - description("Could not read IPC message") - } - CouldNotStartServer { - description("Failed to start the IPC server") - } - InvalidMessage(message: Vec<u8>) { - description("The IPC server got a message it did not know how to handle") - } - } -} |
