pub struct WebSocketMock {
pub url_pattern: String,
pub message_pattern: Option<String>,
pub response: MockWebSocketResponse,
pub once: bool,
pub used: bool,
}Expand description
A WebSocket mock rule
Fields§
§url_pattern: StringURL pattern to match
message_pattern: Option<String>Message pattern to match (for triggered responses)
response: MockWebSocketResponseResponse to send
once: boolWhether this is a one-time mock
used: boolWhether this mock has been used
Implementations§
Source§impl WebSocketMock
impl WebSocketMock
Sourcepub fn on_open(self, response: MockWebSocketResponse) -> Self
pub fn on_open(self, response: MockWebSocketResponse) -> Self
Set response for when connection opens
Sourcepub fn on_message(self, pattern: &str, response: MockWebSocketResponse) -> Self
pub fn on_message(self, pattern: &str, response: MockWebSocketResponse) -> Self
Set response for when message is received
Sourcepub fn matches_url(&self, url: &str) -> bool
pub fn matches_url(&self, url: &str) -> bool
Check if URL matches
Sourcepub fn matches_message(&self, message: &str) -> bool
pub fn matches_message(&self, message: &str) -> bool
Check if message matches
Trait Implementations§
Source§impl Clone for WebSocketMock
impl Clone for WebSocketMock
Source§fn clone(&self) -> WebSocketMock
fn clone(&self) -> WebSocketMock
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for WebSocketMock
impl RefUnwindSafe for WebSocketMock
impl Send for WebSocketMock
impl Sync for WebSocketMock
impl Unpin for WebSocketMock
impl UnsafeUnpin for WebSocketMock
impl UnwindSafe for WebSocketMock
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