pub struct Subprotocol { /* private fields */ }Expand description
The Sec-WebSocket-Protocol value a client offers, in preference order.
OCPP 2.1 Part 4 §3.2 recommends that a 2.1 peer also offer 2.0.1, so a station can talk to a CSMS that has not migrated yet.
Implementations§
Source§impl Subprotocol
impl Subprotocol
Sourcepub fn new(versions: impl IntoIterator<Item = Version>) -> Self
pub fn new(versions: impl IntoIterator<Item = Version>) -> Self
Offers the given versions, most preferred first. Duplicates are removed.
Sourcepub fn header_value(&self) -> String
pub fn header_value(&self) -> String
The Sec-WebSocket-Protocol header value.
Sourcepub fn select(&self, supported: &[Version]) -> Option<Version>
pub fn select(&self, supported: &[Version]) -> Option<Version>
Picks the version a server should select: the first client preference that the server also supports (Part 4 §3.1.2 — the server selects exactly one).
Sourcepub fn accept(
&self,
selected: Option<&str>,
) -> Result<Version, NegotiationError>
pub fn accept( &self, selected: Option<&str>, ) -> Result<Version, NegotiationError>
Validates a server’s selection against what was offered.
Part 4 §3.1.2: the server must echo exactly one of the offered subprotocols. A server that answers with something else, or with nothing, is a negotiation failure.
Trait Implementations§
Source§impl Clone for Subprotocol
impl Clone for Subprotocol
Source§impl Debug for Subprotocol
impl Debug for Subprotocol
Source§impl Default for Subprotocol
impl Default for Subprotocol
impl Eq for Subprotocol
Source§impl PartialEq for Subprotocol
impl PartialEq for Subprotocol
impl StructuralPartialEq for Subprotocol
Auto Trait Implementations§
impl Forget for Subprotocol
impl Freeze for Subprotocol
impl RefUnwindSafe for Subprotocol
impl Send for Subprotocol
impl Sync for Subprotocol
impl Unpin for Subprotocol
impl UnsafeUnpin for Subprotocol
impl UnwindSafe for Subprotocol
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