summaryrefslogtreecommitdiff
path: root/src/event/disconnect.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/event/disconnect.rs')
-rw-r--r--src/event/disconnect.rs25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/event/disconnect.rs b/src/event/disconnect.rs
new file mode 100644
index 0000000..6511027
--- /dev/null
+++ b/src/event/disconnect.rs
@@ -0,0 +1,25 @@
+use std::io;
+
+use getset::Getters;
+
+// TODO : better error type for protocol violation
+pub type ProtocolViolation = String;
+
+pub enum DisconnectReason {
+ Normal,
+ Error(io::Error),
+ ProtocolError(ProtocolViolation),
+ Timeout,
+ ServerShutdown,
+}
+
+#[derive(Getters)]
+pub struct DisconnectEvent<Uid>
+where
+ Uid: PartialEq,
+{
+ #[getset(get = "pub")]
+ connection_id: Uid,
+ #[getset(get = "pub")]
+ reason: DisconnectReason,
+}