[−][src]Struct solana_ws::WebSocket
The WebSocket struct. A WebSocket can support multiple incoming and outgoing connections.
Methods
impl<F> WebSocket<F> where
F: Factory,
[src]
impl<F> WebSocket<F> where
F: Factory,
pub fn new(factory: F) -> Result<WebSocket<F>>
[src]
pub fn new(factory: F) -> Result<WebSocket<F>>
Create a new WebSocket using the given Factory to create handlers.
pub fn bind<A>(self, addr_spec: A) -> Result<WebSocket<F>> where
A: ToSocketAddrs,
[src]
pub fn bind<A>(self, addr_spec: A) -> Result<WebSocket<F>> where
A: ToSocketAddrs,
Consume the WebSocket and bind to the specified address.
If the addr_spec
yields multiple addresses this will return after the
first successful bind. local_addr
can be called to determine which
address it ended up binding to.
After the server is successfully bound you should start it using run
.
pub fn listen<A>(self, addr_spec: A) -> Result<WebSocket<F>> where
A: ToSocketAddrs,
[src]
pub fn listen<A>(self, addr_spec: A) -> Result<WebSocket<F>> where
A: ToSocketAddrs,
Consume the WebSocket and listen for new connections on the specified address.
Safety
This method will block until the event loop finishes running.
pub fn connect(&mut self, url: Url) -> Result<&mut WebSocket<F>>
[src]
pub fn connect(&mut self, url: Url) -> Result<&mut WebSocket<F>>
Queue an outgoing connection on this WebSocket. This method may be called multiple times,
but the actual connections will not be established until run
is called.
pub fn run(self) -> Result<WebSocket<F>>
[src]
pub fn run(self) -> Result<WebSocket<F>>
Run the WebSocket. This will run the encapsulated event loop blocking the calling thread until the WebSocket is shutdown.
pub fn broadcaster(&self) -> Sender
[src]
pub fn broadcaster(&self) -> Sender
Get a Sender that can be used to send messages on all connections.
Calling send
on this Sender is equivalent to calling broadcast
.
Calling shutdown
on this Sender will shutdown the WebSocket even if no connections have
been established.
pub fn local_addr(&self) -> Result<SocketAddr>
[src]
pub fn local_addr(&self) -> Result<SocketAddr>
Get the local socket address this socket is bound to. Will return an error
if the backend returns an error. Will return a NotFound
error if
this WebSocket is not a listening socket.
Auto Trait Implementations
impl<F> Send for WebSocket<F> where
F: Send,
<F as Factory>::Handler: Send,
impl<F> Send for WebSocket<F> where
F: Send,
<F as Factory>::Handler: Send,
impl<F> !Sync for WebSocket<F>
impl<F> !Sync for WebSocket<F>
Blanket Implementations
impl<T> From for T
[src]
impl<T> From for T
impl<T, U> Into for T where
U: From<T>,
[src]
impl<T, U> Into for T where
U: From<T>,
impl<T, U> TryFrom for T where
T: From<U>,
[src]
impl<T, U> TryFrom for T where
T: From<U>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T> Borrow for T where
T: ?Sized,
[src]
impl<T> Borrow for T where
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
impl<T> BorrowMut for T where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
fn borrow_mut(&mut self) -> &mut T
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
impl<T> Any for T where
T: 'static + ?Sized,
[src]
impl<T> Any for T where
T: 'static + ?Sized,
fn get_type_id(&self) -> TypeId
[src]
fn get_type_id(&self) -> TypeId