pub struct WebSocket {
pub url: String,
pub state: WsState,
pub protocol: String,
/* private fields */
}Expand description
Mock WebSocket client with a pending message queue.
Fields§
§url: String§state: WsState§protocol: StringImplementations§
Source§impl WebSocket
impl WebSocket
pub fn new(url: &str) -> Self
pub fn open(&mut self)
pub fn close(&mut self)
pub fn send(&mut self, msg: WsMessage) -> bool
pub fn send_text(&mut self, text: &str) -> bool
pub fn send_json(&mut self, json: &str) -> bool
pub fn recv(&mut self) -> Option<WsMessage>
Sourcepub fn inject_message(&mut self, msg: WsMessage)
pub fn inject_message(&mut self, msg: WsMessage)
Inject a received message (for testing / server push).
pub fn has_pending_send(&self) -> bool
pub fn drain_outgoing(&mut self) -> Vec<WsMessage>
pub fn is_open(&self) -> bool
Auto Trait Implementations§
impl Freeze for WebSocket
impl RefUnwindSafe for WebSocket
impl Send for WebSocket
impl Sync for WebSocket
impl Unpin for WebSocket
impl UnsafeUnpin for WebSocket
impl UnwindSafe for WebSocket
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
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.