pub struct CloseFrame {
pub code: CloseCode,
pub reason: String,
}Expand description
The body of a close frame: a status code, and optionally a reason.
Fields§
§code: CloseCode§reason: StringImplementations§
Source§impl CloseFrame
impl CloseFrame
pub fn new(code: CloseCode, reason: impl Into<String>) -> Self
Sourcepub fn parse(payload: &[u8]) -> WsResult<Option<CloseFrame>>
pub fn parse(payload: &[u8]) -> WsResult<Option<CloseFrame>>
Parse a close payload. An empty payload is legal and means “no status”.
Sourcepub fn to_payload(&self) -> Vec<u8> ⓘ
pub fn to_payload(&self) -> Vec<u8> ⓘ
The wire payload: the code, then the reason.
A control frame carries at most 125 bytes and two of them are the code, so a long reason is truncated on a character boundary rather than being allowed to make an unsendable frame. Reasons are diagnostics, and a diagnostic that kills the connection it explains is worse than a short one.
Trait Implementations§
Source§impl Clone for CloseFrame
impl Clone for CloseFrame
Source§impl Debug for CloseFrame
impl Debug for CloseFrame
impl Eq for CloseFrame
Source§impl PartialEq for CloseFrame
impl PartialEq for CloseFrame
impl StructuralPartialEq for CloseFrame
Auto Trait Implementations§
impl Freeze for CloseFrame
impl RefUnwindSafe for CloseFrame
impl Send for CloseFrame
impl Sync for CloseFrame
impl Unpin for CloseFrame
impl UnsafeUnpin for CloseFrame
impl UnwindSafe for CloseFrame
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more