diff options
| author | denis <denismaximov98@gmail.com> | 2021-01-24 18:38:46 +0200 |
|---|---|---|
| committer | denis <denismaximov98@gmail.com> | 2021-01-24 18:38:46 +0200 |
| commit | b23ef332c7531b8e9bb202bd25e7f37fd157c22c (patch) | |
| tree | 2ad09a6173e8528a91c37609e00c59d9b8a0b04b /src/common/ipc.rs | |
| parent | Merge branch 'main' into server-client (diff) | |
| download | sl0ppij-b23ef332c7531b8e9bb202bd25e7f37fd157c22c.tar.gz sl0ppij-b23ef332c7531b8e9bb202bd25e7f37fd157c22c.tar.xz sl0ppij-b23ef332c7531b8e9bb202bd25e7f37fd157c22c.zip | |
wip: restructing in progress, to prep for server-client
Diffstat (limited to 'src/common/ipc.rs')
| -rw-r--r-- | src/common/ipc.rs | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/common/ipc.rs b/src/common/ipc.rs new file mode 100644 index 00000000..0bfc0451 --- /dev/null +++ b/src/common/ipc.rs @@ -0,0 +1,46 @@ +// IPC stuff for starting to split things into a client and server model +use std::collections::HashSet; +use serde::{Serialize, Deserialize}; + +type SessionID = u64; + +#[derive(PartialEq, Eq, Serialize, Deserialize, Hash)] +pub struct Session { + // Unique ID for this session + id: SessionID, + // Identifier for the underlying IPC primitive (socket, pipe) + conn_name: String, + // User configured alias for the session + alias: String, +} + +// How do we want to connect to a session? +#[derive(Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] +pub enum ClientType { + Reader, + Writer, +} + +// Types of messages sent from the client to the server +#[derive(Serialize, Deserialize)] +pub enum ClientToServerMsg { + // List which sessions are available + ListSessions, + // Create a new session + CreateSession, + // Attach to a running session + AttachToSession(SessionID, ClientType), + // Force detach + DetachSession(SessionID), + // Disconnect from the session we're connected to + DisconnectFromSession, +} + +// Types of messages sent from the server to the client +// @@@ Implement Serialize and Deserialize for this... +pub enum ServerToClientMsg { + // Info about a particular session + SessionInfo(Session), + // A list of sessions + SessionList(HashSet<Session>), +}
\ No newline at end of file |
