diff --git a/src/ws/frame.rs b/src/ws/frame.rs index dfef26b0e..de78b31d2 100644 --- a/src/ws/frame.rs +++ b/src/ws/frame.rs @@ -29,21 +29,21 @@ impl Frame { /// Create a new Close control frame. #[inline] pub fn close(reason: Option, genmask: bool) -> Binary { - let payload = match reason { - None => Vec::new(), - Some(reason) => { - let mut code_bytes = [0; 2]; - NetworkEndian::write_u16(&mut code_bytes, reason.code.into()); + let payload = match reason { + None => Vec::new(), + Some(reason) => { + let mut code_bytes = [0; 2]; + NetworkEndian::write_u16(&mut code_bytes, reason.code.into()); - let mut payload = Vec::from(&code_bytes[..]); - if let Some(description) = reason.description{ - payload.extend(description.as_bytes()); - } - payload - } - }; + let mut payload = Vec::from(&code_bytes[..]); + if let Some(description) = reason.description{ + payload.extend(description.as_bytes()); + } + payload + } + }; - Frame::message(payload, OpCode::Close, true, genmask) + Frame::message(payload, OpCode::Close, true, genmask) } #[cfg_attr(feature = "cargo-clippy", allow(type_complexity))] @@ -529,19 +529,19 @@ mod tests { assert_eq!(frame, v.into()); } - #[test] - fn test_close_frame() { - let reason = (CloseCode::Normal, "data"); - let frame = Frame::close(Some(reason.into()), false); + #[test] + fn test_close_frame() { + let reason = (CloseCode::Normal, "data"); + let frame = Frame::close(Some(reason.into()), false); - let mut v = vec![136u8, 6u8, 3u8, 232u8]; - v.extend(b"data"); - assert_eq!(frame, v.into()); - } + let mut v = vec![136u8, 6u8, 3u8, 232u8]; + v.extend(b"data"); + assert_eq!(frame, v.into()); + } - #[test] - fn test_empty_close_frame() { - let frame = Frame::close(None, false); - assert_eq!(frame, vec![0x88, 0x00].into()); - } + #[test] + fn test_empty_close_frame() { + let frame = Frame::close(None, false); + assert_eq!(frame, vec![0x88, 0x00].into()); + } } diff --git a/src/ws/proto.rs b/src/ws/proto.rs index 954f3f4a7..2851fb9e9 100644 --- a/src/ws/proto.rs +++ b/src/ws/proto.rs @@ -181,26 +181,26 @@ impl From for CloseCode { #[derive(Debug, Eq, PartialEq, Clone)] pub struct CloseReason { - pub code: CloseCode, - pub description: Option, + pub code: CloseCode, + pub description: Option, } impl From for CloseReason { - fn from(code: CloseCode) -> Self { - CloseReason { - code, - description: None, - } - } + fn from(code: CloseCode) -> Self { + CloseReason { + code, + description: None, + } + } } impl > From<(CloseCode, T)> for CloseReason { - fn from(info: (CloseCode, T)) -> Self { - CloseReason{ - code: info.0, - description: Some(info.1.into()) - } - } + fn from(info: (CloseCode, T)) -> Self { + CloseReason{ + code: info.0, + description: Some(info.1.into()) + } + } } static WS_GUID: &'static str = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";