pub struct WebSocketMatcher {
pub frame_type: Option<String>,
pub text_matcher: Option<String>,
pub responses: Option<Vec<WebSocketMessage>>,
pub extra: Extra,
}Expand description
A per-incoming-frame response rule inside an HttpWebSocketResponse::matchers.
When an incoming WebSocket frame matches this rule (by frame_type and/or
text_matcher), the paired responses are sent back.
Unknown fields are captured in extra so the shape round-trips
without loss.
Fields§
§frame_type: Option<String>Frame type to match: "TEXT", "BINARY", "PING", "PONG" or "ANY".
text_matcher: Option<String>Exact-or-regex matcher applied to a text frame’s payload.
responses: Option<Vec<WebSocketMessage>>Messages sent in reply when an incoming frame matches this rule.
extra: ExtraForward-compatibility catch-all for matcher fields not yet named.
Implementations§
Source§impl WebSocketMatcher
impl WebSocketMatcher
Sourcepub fn frame_type(self, frame_type: impl Into<String>) -> Self
pub fn frame_type(self, frame_type: impl Into<String>) -> Self
Set the frame type to match ("TEXT", "BINARY", "PING", "PONG", "ANY").
Sourcepub fn text_matcher(self, text_matcher: impl Into<String>) -> Self
pub fn text_matcher(self, text_matcher: impl Into<String>) -> Self
Set an exact-or-regex matcher for a text frame’s payload.
Sourcepub fn response(self, response: WebSocketMessage) -> Self
pub fn response(self, response: WebSocketMessage) -> Self
Append a reply message sent when an incoming frame matches this rule.
Sourcepub fn responses(self, responses: Vec<WebSocketMessage>) -> Self
pub fn responses(self, responses: Vec<WebSocketMessage>) -> Self
Replace all reply messages.
Trait Implementations§
Source§impl Clone for WebSocketMatcher
impl Clone for WebSocketMatcher
Source§fn clone(&self) -> WebSocketMatcher
fn clone(&self) -> WebSocketMatcher
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for WebSocketMatcher
impl Debug for WebSocketMatcher
Source§impl Default for WebSocketMatcher
impl Default for WebSocketMatcher
Source§fn default() -> WebSocketMatcher
fn default() -> WebSocketMatcher
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for WebSocketMatcher
impl<'de> Deserialize<'de> for WebSocketMatcher
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for WebSocketMatcher
impl PartialEq for WebSocketMatcher
Source§fn eq(&self, other: &WebSocketMatcher) -> bool
fn eq(&self, other: &WebSocketMatcher) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl Serialize for WebSocketMatcher
impl Serialize for WebSocketMatcher
impl StructuralPartialEq for WebSocketMatcher
Auto Trait Implementations§
impl Freeze for WebSocketMatcher
impl RefUnwindSafe for WebSocketMatcher
impl Send for WebSocketMatcher
impl Sync for WebSocketMatcher
impl Unpin for WebSocketMatcher
impl UnsafeUnpin for WebSocketMatcher
impl UnwindSafe for WebSocketMatcher
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