pub struct HttpWebSocketResponse {
pub subprotocol: Option<String>,
pub messages: Option<Vec<WebSocketMessage>>,
pub close_connection: Option<bool>,
pub delay: Option<Delay>,
}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>>§close_connection: Option<bool>§delay: Option<Delay>Implementations§
Source§impl HttpWebSocketResponse
impl HttpWebSocketResponse
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.
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§fn eq(&self, other: &HttpWebSocketResponse) -> bool
fn eq(&self, other: &HttpWebSocketResponse) -> bool
Tests for
self and other values to be equal, and is used by ==.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