Add some message types for server-client comms

This commit is contained in:
Kyle 2021-01-17 19:15:32 +00:00
parent 7efc435bda
commit 09b1e03843
4 changed files with 153 additions and 10 deletions

115
Cargo.lock generated
View File

@ -53,7 +53,7 @@ version = "1.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "00d68a33ebc8b57800847d00787307f84a562224a14db069b0acefe4c2abbf5d"
dependencies = [
"async-task",
"async-task 3.0.0",
"crossbeam-utils 0.7.2",
"futures-channel",
"futures-core",
@ -77,6 +77,12 @@ version = "3.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c17772156ef2829aadc587461c7753af20b7e8db1529bc66855add962a3b35d3"
[[package]]
name = "async-task"
version = "4.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e91831deabf0d6d7ec49552e489aed63b7456a7a3c46cff62adad428110b0af0"
[[package]]
name = "atomic-waker"
version = "1.0.0"
@ -138,12 +144,26 @@ checksum = "d2468ff7bf85066b4a3678fede6fe66db31846d753ff0adfbfab2c6a6e81612b"
dependencies = [
"async-channel",
"atomic-waker",
"futures-lite",
"futures-lite 0.1.10",
"once_cell",
"parking",
"parking 1.0.6",
"waker-fn",
]
[[package]]
name = "blocking"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c5e170dbede1f740736619b776d7251cb1b9095c435c34d8ca9f57fcd2f335e9"
dependencies = [
"async-channel",
"async-task 4.0.3",
"atomic-waker",
"fastrand",
"futures-lite 1.11.3",
"once_cell",
]
[[package]]
name = "bumpalo"
version = "3.4.0"
@ -470,9 +490,12 @@ checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7"
[[package]]
name = "fastrand"
version = "1.3.3"
version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "36a9cb09840f81cd211e435d00a4e487edd263dc3c8ff815c32dd76ad668ebed"
checksum = "ca5faf057445ce5c9d4329e382b2ce7ca38550ef3b73a5348362d5f24e0c7fe3"
dependencies = [
"instant",
]
[[package]]
name = "fnv"
@ -538,11 +561,26 @@ dependencies = [
"futures-core",
"futures-io",
"memchr",
"parking",
"parking 1.0.6",
"pin-project-lite 0.1.7",
"waker-fn",
]
[[package]]
name = "futures-lite"
version = "1.11.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b4481d0cd0de1d204a4fa55e7d45f07b1d958abcb06714b3446438e2eff695fb"
dependencies = [
"fastrand",
"futures-core",
"futures-io",
"memchr",
"parking 2.0.0",
"pin-project-lite 0.2.0",
"waker-fn",
]
[[package]]
name = "futures-macro"
version = "0.3.5"
@ -728,6 +766,38 @@ dependencies = [
"serde_yaml",
]
[[package]]
name = "instant"
version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "61124eeebbd69b8190558df225adf7e4caafce0d743919e5d6b19652314ec5ec"
dependencies = [
"cfg-if 1.0.0",
]
[[package]]
name = "interprocess"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "672deb438b19b22433dcc1b2c75f34c9964e31f325155da06a2dc605706fd264"
dependencies = [
"blocking 1.0.2",
"cfg-if 1.0.0",
"futures",
"intmap",
"lazy_static",
"libc",
"spinning",
"thiserror",
"winapi",
]
[[package]]
name = "intmap"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e50930385956f6c4a0b99f3dd654adcc40788456c36e17c5b20e1d1ceb523ec6"
[[package]]
name = "inventory"
version = "0.1.9"
@ -808,6 +878,15 @@ version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8dd5a6d5999d9907cda8ed67bbd137d3af8085216c2ac62de5be860bd41f304a"
[[package]]
name = "lock_api"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dd96ffd135b2fd7b973ac026d28085defbe8983df057ced3eb4f2130b0831312"
dependencies = [
"scopeguard",
]
[[package]]
name = "log"
version = "0.4.11"
@ -884,6 +963,7 @@ dependencies = [
"bincode",
"futures",
"insta",
"interprocess",
"libc",
"nix",
"serde",
@ -951,9 +1031,9 @@ dependencies = [
[[package]]
name = "once_cell"
version = "1.4.0"
version = "1.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b631f7e854af39a1739f401cf34a8a013dfe09eac4fa4dba91e9768bd28168d"
checksum = "13bd41f508810a131401606d54ac32a467c97172d74ba7662562ebba5ad07fa0"
[[package]]
name = "parking"
@ -961,6 +1041,12 @@ version = "1.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6cb300f271742d4a2a66c01b6b2fa0c83dfebd2e0bf11addb879a3547b4ed87c"
[[package]]
name = "parking"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "427c3892f9e783d91cc128285287e70a59e206ca452770ece88a76f7a3eddd72"
[[package]]
name = "pin-project"
version = "0.4.23"
@ -1333,8 +1419,8 @@ version = "0.1.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "620cbb3c6e34da57d3a248cda0cd01cd5848164dc062e764e65d06fe3ea7aed5"
dependencies = [
"async-task",
"blocking",
"async-task 3.0.0",
"blocking 0.4.7",
"concurrent-queue",
"fastrand",
"futures-io",
@ -1360,6 +1446,15 @@ dependencies = [
"winapi",
]
[[package]]
name = "spinning"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2d4f0e86297cad2658d92a707320d87bf4e6ae1050287f51d19b67ef3f153a7b"
dependencies = [
"lock_api",
]
[[package]]
name = "stable_deref_trait"
version = "1.2.0"

View File

@ -25,6 +25,7 @@ unicode-width = "0.1.8"
vte = "0.8.0"
wasmer = "1.0.0"
wasmer-wasi = "1.0.0"
interprocess = "1.0.1"
[dependencies.async-std]
version = "1.3.0"

46
src/ipc.rs Normal file
View File

@ -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>),
}

View File

@ -6,6 +6,7 @@ mod cli;
mod command_is_executing;
mod errors;
mod input;
mod ipc;
mod layout;
mod os_input_output;
mod panes;