pub struct CloseCode(/* private fields */);Available on crate feature
server only.Expand description
A WebSocket Close status code an endpoint may send (RFC 6455 §7.4).
Only codes a peer accepts can be made: 1000 to 1003 and 1007 to 1013 (RFC 6455 §7.4.1 and the IANA WebSocket Close Code Number Registry), and 3000 to 4999 (§7.4.2: registered libraries and frameworks, and private use). 1004, 1005, 1006 and 1015 must not be sent; 1014 and 1016 to 2999 are rejected by common client libraries (tungstenite treats them as a protocol error).
use jmap_websocket::server::CloseCode;
assert_eq!(CloseCode::POLICY_VIOLATION.as_u16(), 1008);
assert_eq!(CloseCode::new(4001).map(u16::from), Some(4001));
assert_eq!(CloseCode::new(1006), None);Implementations§
Source§impl CloseCode
impl CloseCode
Sourcepub const GOING_AWAY: Self
pub const GOING_AWAY: Self
1001 Going Away, for example a server shutting down.
Sourcepub const POLICY_VIOLATION: Self
pub const POLICY_VIOLATION: Self
1008 Policy Violation: the code RFC 8887 §4.2 names for expired credentials.
Trait Implementations§
impl Copy for CloseCode
impl Eq for CloseCode
impl StructuralPartialEq for CloseCode
Auto Trait Implementations§
impl Forget for CloseCode
impl Freeze for CloseCode
impl Move 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.