Added serde derive to close reason and close code

This commit is contained in:
LucaCappelletti94 2025-02-14 13:37:47 +01:00
parent 9656383646
commit 09dfb88722
2 changed files with 5 additions and 0 deletions

View File

@ -69,6 +69,8 @@ ws = [
"dep:sha1",
]
serde = ["dep:serde"]
# TLS via OpenSSL
openssl = ["__tls", "actix-tls/accept", "actix-tls/openssl"]
@ -121,6 +123,7 @@ language-tags = "0.3"
mime = "0.3.4"
percent-encoding = "2.1"
pin-project-lite = "0.2"
serde = { version = "1", features = ["derive"], optional = true }
smallvec = "1.6.1"
tokio = { version = "1.24.2", features = [] }
tokio-util = { version = "0.7", features = ["io", "codec"] }

View File

@ -83,6 +83,7 @@ impl From<u8> for OpCode {
/// Status code used to indicate why an endpoint is closing the WebSocket connection.
#[derive(Debug, Eq, PartialEq, Clone, Copy)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum CloseCode {
/// Indicates a normal closure, meaning that the purpose for which the connection was
/// established has been fulfilled.
@ -195,6 +196,7 @@ impl From<u16> for CloseCode {
}
#[derive(Debug, Eq, PartialEq, Clone)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
/// Reason for closing the connection
pub struct CloseReason {
/// Exit code