pub struct HttpWebSocketResponse {
pub subprotocol: Option<String>,
pub messages: Option<Vec<WebSocketMessage>>,
pub matchers: Option<Vec<WebSocketMatcher>>,
pub close_connection: Option<bool>,
pub delay: Option<Delay>,
pub template_type: Option<String>,
pub graphql_subscription_filter: Option<GraphqlSubscriptionFilter>,
pub primary: Option<bool>,
pub extra: Extra,
}Expand description
Builder for a WebSocket streaming response action.
Serialized as the httpWebSocketResponse action in an expectation.
§Example
use mockserver_client::{HttpWebSocketResponse, WebSocketMessage};
let ws = HttpWebSocketResponse::new()
.subprotocol("chat")
.message(WebSocketMessage::text("hello"))
.message(WebSocketMessage::binary([0x01, 0x02]))
.close_connection(true);Fields§
§subprotocol: Option<String>§messages: Option<Vec<WebSocketMessage>>§matchers: Option<Vec<WebSocketMatcher>>Per-incoming-frame response rules; when set, an incoming frame matching a
rule triggers that rule’s responses.
close_connection: Option<bool>§delay: Option<Delay>§template_type: Option<String>§graphql_subscription_filter: Option<GraphqlSubscriptionFilter>GraphQL subscription query filter for the graphql-transport-ws protocol.
primary: Option<bool>§extra: ExtraCatch-all for server fields this client does not model yet, so a retrieve -> re-submit cycle cannot silently destroy them.
Implementations§
Source§impl HttpWebSocketResponse
impl HttpWebSocketResponse
Sourcepub fn matcher(self, matcher: WebSocketMatcher) -> Self
pub fn matcher(self, matcher: WebSocketMatcher) -> Self
Append an incoming-frame matcher rule.
Sourcepub fn matchers(self, matchers: Vec<WebSocketMatcher>) -> Self
pub fn matchers(self, matchers: Vec<WebSocketMatcher>) -> Self
Replace all incoming-frame matcher rules.
Sourcepub fn subprotocol(self, subprotocol: impl Into<String>) -> Self
pub fn subprotocol(self, subprotocol: impl Into<String>) -> Self
Set the negotiated subprotocol.
Sourcepub fn message(self, message: WebSocketMessage) -> Self
pub fn message(self, message: WebSocketMessage) -> Self
Append a WebSocket message to send.
Sourcepub fn messages(self, messages: Vec<WebSocketMessage>) -> Self
pub fn messages(self, messages: Vec<WebSocketMessage>) -> Self
Replace all WebSocket messages.
Sourcepub fn close_connection(self, close: bool) -> Self
pub fn close_connection(self, close: bool) -> Self
Whether to close the connection after emitting all messages.
Sourcepub fn template_type(self, template_type: impl Into<String>) -> Self
pub fn template_type(self, template_type: impl Into<String>) -> Self
Set the template type (VELOCITY, JAVASCRIPT or MUSTACHE).
Sourcepub fn graphql_subscription_filter(
self,
filter: GraphqlSubscriptionFilter,
) -> Self
pub fn graphql_subscription_filter( self, filter: GraphqlSubscriptionFilter, ) -> Self
Set the GraphQL subscription filter.
Trait Implementations§
Source§impl Clone for HttpWebSocketResponse
impl Clone for HttpWebSocketResponse
Source§fn clone(&self) -> HttpWebSocketResponse
fn clone(&self) -> HttpWebSocketResponse
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 HttpWebSocketResponse
impl Debug for HttpWebSocketResponse
Source§impl Default for HttpWebSocketResponse
impl Default for HttpWebSocketResponse
Source§fn default() -> HttpWebSocketResponse
fn default() -> HttpWebSocketResponse
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for HttpWebSocketResponse
impl<'de> Deserialize<'de> for HttpWebSocketResponse
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 HttpWebSocketResponse
impl PartialEq for HttpWebSocketResponse
Source§impl Serialize for HttpWebSocketResponse
impl Serialize for HttpWebSocketResponse
impl StructuralPartialEq for HttpWebSocketResponse
Auto Trait Implementations§
impl Freeze for HttpWebSocketResponse
impl RefUnwindSafe for HttpWebSocketResponse
impl Send for HttpWebSocketResponse
impl Sync for HttpWebSocketResponse
impl Unpin for HttpWebSocketResponse
impl UnsafeUnpin for HttpWebSocketResponse
impl UnwindSafe for HttpWebSocketResponse
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