diff options
author | stale <redkugelblitzin@gmail.com> | 2022-05-07 21:38:25 -0300 |
---|---|---|
committer | stale <redkugelblitzin@gmail.com> | 2022-05-07 21:38:25 -0300 |
commit | ac938b0d57d2e2630bf05668fec6b3d6c18d0450 (patch) | |
tree | d591b5a48b6c4974854c578bc157a7a8ffa2414c /src/types.rs | |
parent | 88cc92f64dfc4a241410f67b20dec4680461a344 (diff) |
this don't work no good
Diffstat (limited to 'src/types.rs')
-rw-r--r-- | src/types.rs | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/types.rs b/src/types.rs new file mode 100644 index 0000000..eed69dd --- /dev/null +++ b/src/types.rs @@ -0,0 +1,43 @@ +use std::{ + collections::HashMap, + net::SocketAddr, + sync::Arc, +}; +use tokio::sync::RwLock; +use hyper_tungstenite::tungstenite::Message; +use hyper::{ Response, Body }; +use futures::channel::mpsc::UnboundedSender; +use crate::minesweeper; + +#[derive(Debug, Clone)] +pub struct Config { + pub cert_path: String, + pub pkey_path: String, + pub page_path: String, + pub socket_addr: SocketAddr, +} + +#[derive(Debug, Clone)] +pub struct State { + pub conf: Config, + pub peers: PeerMap, +} + +#[derive(Debug)] +pub enum MetaMove { + Move(minesweeper::Move,SocketAddr), + Dump, + Reset, +} + +#[derive(Debug)] +pub struct Peer { + pub tx: UnboundedSender<Message>, + pub seq_id: usize, + pub name: String, + pub position: (usize, usize), +} + +pub type HtmlResult = Result<Response<Body>, Response<Body>>; +pub type MovReqTx = futures::channel::mpsc::UnboundedSender<MetaMove>; +pub type PeerMap = Arc<RwLock<HashMap<SocketAddr, Peer>>>; |