pub struct CloseCode(pub u16);Expand description
A close status code.
A newtype rather than an enum because the range 3000–4999 belongs to the application and must survive a round trip unchanged.
Tuple Fields§
§0: u16Implementations§
Source§impl CloseCode
impl CloseCode
pub const NORMAL: CloseCode
pub const GOING_AWAY: CloseCode
pub const PROTOCOL_ERROR: CloseCode
pub const UNSUPPORTED: CloseCode
Sourcepub const NO_STATUS: CloseCode
pub const NO_STATUS: CloseCode
Never sent on the wire: it means “the peer closed without a code”.
pub const INVALID_PAYLOAD: CloseCode
pub const POLICY: CloseCode
pub const TOO_LARGE: CloseCode
pub const INTERNAL_ERROR: CloseCode
pub fn code(self) -> u16
Sourcepub fn is_sendable(self) -> bool
pub fn is_sendable(self) -> bool
Whether this code is one a peer is allowed to put in a close frame.
Two different reasons a code in 1000–1015 may not be sent:
- 1005, 1006 and 1015 describe how a connection ended locally — no status given, closed abnormally, TLS failed. They exist for an API to report, and a peer putting one on the wire is lying about what happened. Clients do occasionally try.
- 1004 is reserved (RFC 6455 §7.4.1). It has no meaning, so a peer
sending it is sending nothing we can act on. It used to fall inside
1000..=1014and was accepted and echoed back; the Autobahn TestSuite’s case 7.9.3 caught it.
1012, 1013 and 1014 stay sendable: IANA registered them after the RFC — service restart, try again later, bad gateway.
Trait Implementations§
impl Copy for CloseCode
impl Eq for CloseCode
impl StructuralPartialEq for CloseCode
Auto Trait Implementations§
impl Freeze for CloseCode
impl RefUnwindSafe for CloseCode
impl Send for CloseCode
impl Sync for CloseCode
impl Unpin for CloseCode
impl UnsafeUnpin for CloseCode
impl UnwindSafe for CloseCode
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