[−][src]Struct websocket::server::WsServer
Represents a WebSocket server which can work with either normal (non-secure) connections, or secure WebSocket connections.
This is a convenient way to implement WebSocket servers, however it is possible to use any sendable Reader and Writer to obtain a WebSocketClient, so if needed, an alternative server implementation can be used.
Synchronous Servers
Synchronous implementations of a websocket server are available below, each method is documented so the reader knows whether is it synchronous or asynchronous.
To use the synchronous implementation, you must have the sync
feature enabled
(it is enabled by default).
To use the synchronous SSL implementation, you must have the sync-ssl
feature enabled
(it is enabled by default).
Asynchronous Servers
Asynchronous implementations of a websocket server are available below, each method is
documented so the reader knows whether is it synchronous or asynchronous.
Simply look out for the implementation of Server
whose methods only return Future
s
(it is also written in the docs if the method is async).
To use the asynchronous implementation, you must have the async
feature enabled
(it is enabled by default).
To use the asynchronous SSL implementation, you must have the async-ssl
feature enabled
(it is enabled by default).
A Hyper Server
This crates comes with hyper integration out of the box, you can create a hyper
server and serve websocket and HTTP on the same port!
check out the docs over at websocket::server::upgrade::sync::HyperRequest
for an example.
A Custom Server
So you don't want to use any of our server implementations? That's O.K.
All it takes is implementing the IntoWs
trait for your server's streams,
then calling .into_ws()
on them.
check out the docs over at websocket::server::upgrade::sync
for more.
Fields
ssl_acceptor: S
The SSL acceptor given to the server
Methods
impl WsServer<NoTlsAcceptor, TcpListener>
[src]
impl WsServer<NoTlsAcceptor, TcpListener>
Asynchronous methods for creating an async server and accepting incoming connections.
pub fn bind<A: ToSocketAddrs>(addr: A, handle: &Handle) -> Result<Self>
[src]
pub fn bind<A: ToSocketAddrs>(addr: A, handle: &Handle) -> Result<Self>
Bind a websocket server to an address.
Creating a websocket server can be done immediately so this does not
return a Future
but a simple Result
.
pub fn incoming(self) -> Incoming<TcpStream>
[src]
pub fn incoming(self) -> Incoming<TcpStream>
Turns the server into a stream of connection objects.
Each item of the stream is the address of the incoming connection and an Upgrade
struct which lets the user decide whether to turn the connection into a websocket
connection or reject it.
See the [examples/async-server.rs
]
(https://github.com/cyderize/rust-websocket/blob/master/examples/async-server.rs)
example for a good echo server example.
impl WsServer<TlsAcceptor, TcpListener>
[src]
impl WsServer<TlsAcceptor, TcpListener>
Asynchronous methods for creating an async SSL server and accepting incoming connections.
pub fn bind_secure<A: ToSocketAddrs>(
addr: A,
acceptor: TlsAcceptor,
handle: &Handle
) -> Result<Self>
[src]
pub fn bind_secure<A: ToSocketAddrs>(
addr: A,
acceptor: TlsAcceptor,
handle: &Handle
) -> Result<Self>
Bind an SSL websocket server to an address.
Creating a websocket server can be done immediately so this does not
return a Future
but a simple Result
.
Since this is an SSL server one needs to provide a TlsAcceptor
that contains
the server's SSL information.
pub fn incoming(self) -> Incoming<TlsStream<TcpStream>>
[src]
pub fn incoming(self) -> Incoming<TlsStream<TcpStream>>
Turns the server into a stream of connection objects.
Each item of the stream is the address of the incoming connection and an Upgrade
struct which lets the user decide whether to turn the connection into a websocket
connection or reject it.
See the [examples/async-server.rs
]
(https://github.com/cyderize/rust-websocket/blob/master/examples/async-server.rs)
example for a good echo server example.
impl<S> WsServer<S, TcpListener> where
S: OptionalTlsAcceptor,
[src]
impl<S> WsServer<S, TcpListener> where
S: OptionalTlsAcceptor,
Synchronous methods for creating a server and accepting incoming connections.
pub fn local_addr(&self) -> Result<SocketAddr>
[src]
pub fn local_addr(&self) -> Result<SocketAddr>
Get the socket address of this server
pub fn set_nonblocking(&self, nonblocking: bool) -> Result<()>
[src]
pub fn set_nonblocking(&self, nonblocking: bool) -> Result<()>
Changes whether the Server is in nonblocking mode.
NOTE: It is strongly encouraged to use the websocket::async
module instead
of this. It provides high level APIs for creating asynchronous servers.
If it is in nonblocking mode, accept() will return an error instead of blocking when there are no incoming connections.
// Suppose we have to work in a single thread, but want to // accomplish two unrelated things: // (1) Once in a while we want to check if anybody tried to connect to // our websocket server, and if so, handle the TcpStream. // (2) In between we need to something else, possibly unrelated to networking. let mut server = Server::bind("127.0.0.1:0").unwrap(); // Set the server to non-blocking. server.set_nonblocking(true); for i in 1..3 { let result = match server.accept() { Ok(wsupgrade) => { // Do something with the established TcpStream. } _ => { // Nobody tried to connect, move on. } }; // Perform another task. Because we have a non-blocking server, // this will execute independent of whether someone tried to // establish a connection. let two = 1+1; }
pub fn into_async(self, handle: &Handle) -> Result<Server<S>>
[src]
pub fn into_async(self, handle: &Handle) -> Result<Server<S>>
Turns an existing synchronous server into an asynchronous one.
This will only work if the stream used for this server S
already implements
AsyncRead + AsyncWrite
. Useful if you would like some blocking things to happen
at the start of your server.
impl WsServer<TlsAcceptor, TcpListener>
[src]
impl WsServer<TlsAcceptor, TcpListener>
Synchronous methods for creating an SSL server and accepting incoming connections.
pub fn bind_secure<A>(addr: A, acceptor: TlsAcceptor) -> Result<Self> where
A: ToSocketAddrs,
[src]
pub fn bind_secure<A>(addr: A, acceptor: TlsAcceptor) -> Result<Self> where
A: ToSocketAddrs,
Bind this Server to this socket, utilising the given SslContext
Secure Servers
extern crate websocket; extern crate native_tls; use std::thread; use std::io::Read; use std::fs::File; use websocket::Message; use websocket::sync::Server; use native_tls::{Identity, TlsAcceptor}; // In this example we retrieve our keypair and certificate chain from a PKCS #12 archive, // but but they can also be retrieved from, for example, individual PEM- or DER-formatted // files. See the documentation for the `PKey` and `X509` types for more details. let mut file = File::open("identity.pfx").unwrap(); let mut pkcs12 = vec![]; file.read_to_end(&mut pkcs12).unwrap(); let pkcs12 = Identity::from_pkcs12(&pkcs12, "hacktheplanet").unwrap(); let acceptor = TlsAcceptor::builder(pkcs12).build().unwrap(); let server = Server::bind_secure("127.0.0.1:1234", acceptor).unwrap(); for connection in server.filter_map(Result::ok) { // Spawn a new thread for each connection. thread::spawn(move || { let mut client = connection.accept().unwrap(); let message = Message::text("Hello, client!"); let _ = client.send_message(&message); // ... }); }
pub fn accept(&mut self) -> AcceptResult<TlsStream<TcpStream>>
[src]
pub fn accept(&mut self) -> AcceptResult<TlsStream<TcpStream>>
Wait for and accept an incoming WebSocket connection, returning a WebSocketRequest
impl WsServer<NoTlsAcceptor, TcpListener>
[src]
impl WsServer<NoTlsAcceptor, TcpListener>
pub fn bind<A: ToSocketAddrs>(addr: A) -> Result<Self>
[src]
pub fn bind<A: ToSocketAddrs>(addr: A) -> Result<Self>
Bind this Server to this socket
Non-secure Servers
extern crate websocket; use std::thread; use websocket::Message; use websocket::sync::Server; let server = Server::bind("127.0.0.1:1234").unwrap(); for connection in server.filter_map(Result::ok) { // Spawn a new thread for each connection. thread::spawn(move || { let mut client = connection.accept().unwrap(); let message = Message::text("Hello, client!"); let _ = client.send_message(&message); // ... }); }
pub fn accept(&mut self) -> AcceptResult<TcpStream>
[src]
pub fn accept(&mut self) -> AcceptResult<TcpStream>
Wait for and accept an incoming WebSocket connection, returning a WebSocketRequest
pub fn try_clone(&self) -> Result<Self>
[src]
pub fn try_clone(&self) -> Result<Self>
Create a new independently owned handle to the underlying socket.
Trait Implementations
impl Iterator for WsServer<TlsAcceptor, TcpListener>
[src]
impl Iterator for WsServer<TlsAcceptor, TcpListener>
type Item = AcceptResult<TlsStream<TcpStream>>
The type of the elements being iterated over.
fn next(&mut self) -> Option<Self::Item>
[src]
fn next(&mut self) -> Option<Self::Item>
Advances the iterator and returns the next value. Read more
fn size_hint(&self) -> (usize, Option<usize>)
1.0.0[src]
fn size_hint(&self) -> (usize, Option<usize>)
Returns the bounds on the remaining length of the iterator. Read more
fn count(self) -> usize
1.0.0[src]
fn count(self) -> usize
Consumes the iterator, counting the number of iterations and returning it. Read more
fn last(self) -> Option<Self::Item>
1.0.0[src]
fn last(self) -> Option<Self::Item>
Consumes the iterator, returning the last element. Read more
fn nth(&mut self, n: usize) -> Option<Self::Item>
1.0.0[src]
fn nth(&mut self, n: usize) -> Option<Self::Item>
Returns the n
th element of the iterator. Read more
fn step_by(self, step: usize) -> StepBy<Self>
1.28.0[src]
fn step_by(self, step: usize) -> StepBy<Self>
Creates an iterator starting at the same point, but stepping by the given amount at each iteration. Read more
fn chain<U>(self, other: U) -> Chain<Self, <U as IntoIterator>::IntoIter> where
U: IntoIterator<Item = Self::Item>,
1.0.0[src]
fn chain<U>(self, other: U) -> Chain<Self, <U as IntoIterator>::IntoIter> where
U: IntoIterator<Item = Self::Item>,
Takes two iterators and creates a new iterator over both in sequence. Read more
fn zip<U>(self, other: U) -> Zip<Self, <U as IntoIterator>::IntoIter> where
U: IntoIterator,
1.0.0[src]
fn zip<U>(self, other: U) -> Zip<Self, <U as IntoIterator>::IntoIter> where
U: IntoIterator,
'Zips up' two iterators into a single iterator of pairs. Read more
fn map<B, F>(self, f: F) -> Map<Self, F> where
F: FnMut(Self::Item) -> B,
1.0.0[src]
fn map<B, F>(self, f: F) -> Map<Self, F> where
F: FnMut(Self::Item) -> B,
Takes a closure and creates an iterator which calls that closure on each element. Read more
fn for_each<F>(self, f: F) where
F: FnMut(Self::Item),
1.21.0[src]
fn for_each<F>(self, f: F) where
F: FnMut(Self::Item),
Calls a closure on each element of an iterator. Read more
fn filter<P>(self, predicate: P) -> Filter<Self, P> where
P: FnMut(&Self::Item) -> bool,
1.0.0[src]
fn filter<P>(self, predicate: P) -> Filter<Self, P> where
P: FnMut(&Self::Item) -> bool,
Creates an iterator which uses a closure to determine if an element should be yielded. Read more
fn filter_map<B, F>(self, f: F) -> FilterMap<Self, F> where
F: FnMut(Self::Item) -> Option<B>,
1.0.0[src]
fn filter_map<B, F>(self, f: F) -> FilterMap<Self, F> where
F: FnMut(Self::Item) -> Option<B>,
Creates an iterator that both filters and maps. Read more
fn enumerate(self) -> Enumerate<Self>
1.0.0[src]
fn enumerate(self) -> Enumerate<Self>
Creates an iterator which gives the current iteration count as well as the next value. Read more
fn peekable(self) -> Peekable<Self>
1.0.0[src]
fn peekable(self) -> Peekable<Self>
Creates an iterator which can use peek
to look at the next element of the iterator without consuming it. Read more
fn skip_while<P>(self, predicate: P) -> SkipWhile<Self, P> where
P: FnMut(&Self::Item) -> bool,
1.0.0[src]
fn skip_while<P>(self, predicate: P) -> SkipWhile<Self, P> where
P: FnMut(&Self::Item) -> bool,
Creates an iterator that [skip
]s elements based on a predicate. Read more
fn take_while<P>(self, predicate: P) -> TakeWhile<Self, P> where
P: FnMut(&Self::Item) -> bool,
1.0.0[src]
fn take_while<P>(self, predicate: P) -> TakeWhile<Self, P> where
P: FnMut(&Self::Item) -> bool,
Creates an iterator that yields elements based on a predicate. Read more
fn skip(self, n: usize) -> Skip<Self>
1.0.0[src]
fn skip(self, n: usize) -> Skip<Self>
Creates an iterator that skips the first n
elements. Read more
fn take(self, n: usize) -> Take<Self>
1.0.0[src]
fn take(self, n: usize) -> Take<Self>
Creates an iterator that yields its first n
elements. Read more
fn scan<St, B, F>(self, initial_state: St, f: F) -> Scan<Self, St, F> where
F: FnMut(&mut St, Self::Item) -> Option<B>,
1.0.0[src]
fn scan<St, B, F>(self, initial_state: St, f: F) -> Scan<Self, St, F> where
F: FnMut(&mut St, Self::Item) -> Option<B>,
An iterator adaptor similar to [fold
] that holds internal state and produces a new iterator. Read more
fn flat_map<U, F>(self, f: F) -> FlatMap<Self, U, F> where
F: FnMut(Self::Item) -> U,
U: IntoIterator,
1.0.0[src]
fn flat_map<U, F>(self, f: F) -> FlatMap<Self, U, F> where
F: FnMut(Self::Item) -> U,
U: IntoIterator,
Creates an iterator that works like map, but flattens nested structure. Read more
fn flatten(self) -> Flatten<Self> where
Self::Item: IntoIterator,
1.29.0[src]
fn flatten(self) -> Flatten<Self> where
Self::Item: IntoIterator,
Creates an iterator that flattens nested structure. Read more
fn fuse(self) -> Fuse<Self>
1.0.0[src]
fn fuse(self) -> Fuse<Self>
Creates an iterator which ends after the first [None
]. Read more
fn inspect<F>(self, f: F) -> Inspect<Self, F> where
F: FnMut(&Self::Item),
1.0.0[src]
fn inspect<F>(self, f: F) -> Inspect<Self, F> where
F: FnMut(&Self::Item),
Do something with each element of an iterator, passing the value on. Read more
fn by_ref(&mut self) -> &mut Self
1.0.0[src]
fn by_ref(&mut self) -> &mut Self
Borrows an iterator, rather than consuming it. Read more
#[must_use = "if you really need to exhaust the iterator, consider `.for_each(drop)` instead"]
fn collect<B>(self) -> B where
B: FromIterator<Self::Item>,
1.0.0[src]
#[must_use = "if you really need to exhaust the iterator, consider `.for_each(drop)` instead"]
fn collect<B>(self) -> B where
B: FromIterator<Self::Item>,
Transforms an iterator into a collection. Read more
fn partition<B, F>(self, f: F) -> (B, B) where
B: Default + Extend<Self::Item>,
F: FnMut(&Self::Item) -> bool,
1.0.0[src]
fn partition<B, F>(self, f: F) -> (B, B) where
B: Default + Extend<Self::Item>,
F: FnMut(&Self::Item) -> bool,
Consumes an iterator, creating two collections from it. Read more
fn try_fold<B, F, R>(&mut self, init: B, f: F) -> R where
F: FnMut(B, Self::Item) -> R,
R: Try<Ok = B>,
1.27.0[src]
fn try_fold<B, F, R>(&mut self, init: B, f: F) -> R where
F: FnMut(B, Self::Item) -> R,
R: Try<Ok = B>,
An iterator method that applies a function as long as it returns successfully, producing a single, final value. Read more
fn try_for_each<F, R>(&mut self, f: F) -> R where
F: FnMut(Self::Item) -> R,
R: Try<Ok = ()>,
1.27.0[src]
fn try_for_each<F, R>(&mut self, f: F) -> R where
F: FnMut(Self::Item) -> R,
R: Try<Ok = ()>,
An iterator method that applies a fallible function to each item in the iterator, stopping at the first error and returning that error. Read more
fn fold<B, F>(self, init: B, f: F) -> B where
F: FnMut(B, Self::Item) -> B,
1.0.0[src]
fn fold<B, F>(self, init: B, f: F) -> B where
F: FnMut(B, Self::Item) -> B,
An iterator method that applies a function, producing a single, final value. Read more
fn all<F>(&mut self, f: F) -> bool where
F: FnMut(Self::Item) -> bool,
1.0.0[src]
fn all<F>(&mut self, f: F) -> bool where
F: FnMut(Self::Item) -> bool,
Tests if every element of the iterator matches a predicate. Read more
fn any<F>(&mut self, f: F) -> bool where
F: FnMut(Self::Item) -> bool,
1.0.0[src]
fn any<F>(&mut self, f: F) -> bool where
F: FnMut(Self::Item) -> bool,
Tests if any element of the iterator matches a predicate. Read more
fn find<P>(&mut self, predicate: P) -> Option<Self::Item> where
P: FnMut(&Self::Item) -> bool,
1.0.0[src]
fn find<P>(&mut self, predicate: P) -> Option<Self::Item> where
P: FnMut(&Self::Item) -> bool,
Searches for an element of an iterator that satisfies a predicate. Read more
fn find_map<B, F>(&mut self, f: F) -> Option<B> where
F: FnMut(Self::Item) -> Option<B>,
1.30.0[src]
fn find_map<B, F>(&mut self, f: F) -> Option<B> where
F: FnMut(Self::Item) -> Option<B>,
Applies function to the elements of iterator and returns the first non-none result. Read more
fn position<P>(&mut self, predicate: P) -> Option<usize> where
P: FnMut(Self::Item) -> bool,
1.0.0[src]
fn position<P>(&mut self, predicate: P) -> Option<usize> where
P: FnMut(Self::Item) -> bool,
Searches for an element in an iterator, returning its index. Read more
fn rposition<P>(&mut self, predicate: P) -> Option<usize> where
P: FnMut(Self::Item) -> bool,
Self: ExactSizeIterator + DoubleEndedIterator,
1.0.0[src]
fn rposition<P>(&mut self, predicate: P) -> Option<usize> where
P: FnMut(Self::Item) -> bool,
Self: ExactSizeIterator + DoubleEndedIterator,
Searches for an element in an iterator from the right, returning its index. Read more
fn max(self) -> Option<Self::Item> where
Self::Item: Ord,
1.0.0[src]
fn max(self) -> Option<Self::Item> where
Self::Item: Ord,
Returns the maximum element of an iterator. Read more
fn min(self) -> Option<Self::Item> where
Self::Item: Ord,
1.0.0[src]
fn min(self) -> Option<Self::Item> where
Self::Item: Ord,
Returns the minimum element of an iterator. Read more
fn max_by_key<B, F>(self, f: F) -> Option<Self::Item> where
B: Ord,
F: FnMut(&Self::Item) -> B,
1.6.0[src]
fn max_by_key<B, F>(self, f: F) -> Option<Self::Item> where
B: Ord,
F: FnMut(&Self::Item) -> B,
Returns the element that gives the maximum value from the specified function. Read more
fn max_by<F>(self, compare: F) -> Option<Self::Item> where
F: FnMut(&Self::Item, &Self::Item) -> Ordering,
1.15.0[src]
fn max_by<F>(self, compare: F) -> Option<Self::Item> where
F: FnMut(&Self::Item, &Self::Item) -> Ordering,
Returns the element that gives the maximum value with respect to the specified comparison function. Read more
fn min_by_key<B, F>(self, f: F) -> Option<Self::Item> where
B: Ord,
F: FnMut(&Self::Item) -> B,
1.6.0[src]
fn min_by_key<B, F>(self, f: F) -> Option<Self::Item> where
B: Ord,
F: FnMut(&Self::Item) -> B,
Returns the element that gives the minimum value from the specified function. Read more
fn min_by<F>(self, compare: F) -> Option<Self::Item> where
F: FnMut(&Self::Item, &Self::Item) -> Ordering,
1.15.0[src]
fn min_by<F>(self, compare: F) -> Option<Self::Item> where
F: FnMut(&Self::Item, &Self::Item) -> Ordering,
Returns the element that gives the minimum value with respect to the specified comparison function. Read more
fn rev(self) -> Rev<Self> where
Self: DoubleEndedIterator,
1.0.0[src]
fn rev(self) -> Rev<Self> where
Self: DoubleEndedIterator,
Reverses an iterator's direction. Read more
fn unzip<A, B, FromA, FromB>(self) -> (FromA, FromB) where
FromA: Default + Extend<A>,
FromB: Default + Extend<B>,
Self: Iterator<Item = (A, B)>,
1.0.0[src]
fn unzip<A, B, FromA, FromB>(self) -> (FromA, FromB) where
FromA: Default + Extend<A>,
FromB: Default + Extend<B>,
Self: Iterator<Item = (A, B)>,
Converts an iterator of pairs into a pair of containers. Read more
fn cloned<'a, T>(self) -> Cloned<Self> where
Self: Iterator<Item = &'a T>,
T: 'a + Clone,
1.0.0[src]
fn cloned<'a, T>(self) -> Cloned<Self> where
Self: Iterator<Item = &'a T>,
T: 'a + Clone,
Creates an iterator which [clone
]s all of its elements. Read more
fn cycle(self) -> Cycle<Self> where
Self: Clone,
1.0.0[src]
fn cycle(self) -> Cycle<Self> where
Self: Clone,
Repeats an iterator endlessly. Read more
fn sum<S>(self) -> S where
S: Sum<Self::Item>,
1.11.0[src]
fn sum<S>(self) -> S where
S: Sum<Self::Item>,
Sums the elements of an iterator. Read more
fn product<P>(self) -> P where
P: Product<Self::Item>,
1.11.0[src]
fn product<P>(self) -> P where
P: Product<Self::Item>,
Iterates over the entire iterator, multiplying all the elements Read more
fn cmp<I>(self, other: I) -> Ordering where
I: IntoIterator<Item = Self::Item>,
Self::Item: Ord,
1.5.0[src]
fn cmp<I>(self, other: I) -> Ordering where
I: IntoIterator<Item = Self::Item>,
Self::Item: Ord,
Lexicographically compares the elements of this Iterator
with those of another. Read more
fn partial_cmp<I>(self, other: I) -> Option<Ordering> where
I: IntoIterator,
Self::Item: PartialOrd<<I as IntoIterator>::Item>,
1.5.0[src]
fn partial_cmp<I>(self, other: I) -> Option<Ordering> where
I: IntoIterator,
Self::Item: PartialOrd<<I as IntoIterator>::Item>,
Lexicographically compares the elements of this Iterator
with those of another. Read more
fn eq<I>(self, other: I) -> bool where
I: IntoIterator,
Self::Item: PartialEq<<I as IntoIterator>::Item>,
1.5.0[src]
fn eq<I>(self, other: I) -> bool where
I: IntoIterator,
Self::Item: PartialEq<<I as IntoIterator>::Item>,
Determines if the elements of this Iterator
are equal to those of another. Read more
fn ne<I>(self, other: I) -> bool where
I: IntoIterator,
Self::Item: PartialEq<<I as IntoIterator>::Item>,
1.5.0[src]
fn ne<I>(self, other: I) -> bool where
I: IntoIterator,
Self::Item: PartialEq<<I as IntoIterator>::Item>,
Determines if the elements of this Iterator
are unequal to those of another. Read more
fn lt<I>(self, other: I) -> bool where
I: IntoIterator,
Self::Item: PartialOrd<<I as IntoIterator>::Item>,
1.5.0[src]
fn lt<I>(self, other: I) -> bool where
I: IntoIterator,
Self::Item: PartialOrd<<I as IntoIterator>::Item>,
Determines if the elements of this Iterator
are lexicographically less than those of another. Read more
fn le<I>(self, other: I) -> bool where
I: IntoIterator,
Self::Item: PartialOrd<<I as IntoIterator>::Item>,
1.5.0[src]
fn le<I>(self, other: I) -> bool where
I: IntoIterator,
Self::Item: PartialOrd<<I as IntoIterator>::Item>,
Determines if the elements of this Iterator
are lexicographically less or equal to those of another. Read more
fn gt<I>(self, other: I) -> bool where
I: IntoIterator,
Self::Item: PartialOrd<<I as IntoIterator>::Item>,
1.5.0[src]
fn gt<I>(self, other: I) -> bool where
I: IntoIterator,
Self::Item: PartialOrd<<I as IntoIterator>::Item>,
Determines if the elements of this Iterator
are lexicographically greater than those of another. Read more
fn ge<I>(self, other: I) -> bool where
I: IntoIterator,
Self::Item: PartialOrd<<I as IntoIterator>::Item>,
1.5.0[src]
fn ge<I>(self, other: I) -> bool where
I: IntoIterator,
Self::Item: PartialOrd<<I as IntoIterator>::Item>,
Determines if the elements of this Iterator
are lexicographically greater than or equal to those of another. Read more
impl Iterator for WsServer<NoTlsAcceptor, TcpListener>
[src]
impl Iterator for WsServer<NoTlsAcceptor, TcpListener>
type Item = AcceptResult<TcpStream>
The type of the elements being iterated over.
fn next(&mut self) -> Option<Self::Item>
[src]
fn next(&mut self) -> Option<Self::Item>
Advances the iterator and returns the next value. Read more
fn size_hint(&self) -> (usize, Option<usize>)
1.0.0[src]
fn size_hint(&self) -> (usize, Option<usize>)
Returns the bounds on the remaining length of the iterator. Read more
fn count(self) -> usize
1.0.0[src]
fn count(self) -> usize
Consumes the iterator, counting the number of iterations and returning it. Read more
fn last(self) -> Option<Self::Item>
1.0.0[src]
fn last(self) -> Option<Self::Item>
Consumes the iterator, returning the last element. Read more
fn nth(&mut self, n: usize) -> Option<Self::Item>
1.0.0[src]
fn nth(&mut self, n: usize) -> Option<Self::Item>
Returns the n
th element of the iterator. Read more
fn step_by(self, step: usize) -> StepBy<Self>
1.28.0[src]
fn step_by(self, step: usize) -> StepBy<Self>
Creates an iterator starting at the same point, but stepping by the given amount at each iteration. Read more
fn chain<U>(self, other: U) -> Chain<Self, <U as IntoIterator>::IntoIter> where
U: IntoIterator<Item = Self::Item>,
1.0.0[src]
fn chain<U>(self, other: U) -> Chain<Self, <U as IntoIterator>::IntoIter> where
U: IntoIterator<Item = Self::Item>,
Takes two iterators and creates a new iterator over both in sequence. Read more
fn zip<U>(self, other: U) -> Zip<Self, <U as IntoIterator>::IntoIter> where
U: IntoIterator,
1.0.0[src]
fn zip<U>(self, other: U) -> Zip<Self, <U as IntoIterator>::IntoIter> where
U: IntoIterator,
'Zips up' two iterators into a single iterator of pairs. Read more
fn map<B, F>(self, f: F) -> Map<Self, F> where
F: FnMut(Self::Item) -> B,
1.0.0[src]
fn map<B, F>(self, f: F) -> Map<Self, F> where
F: FnMut(Self::Item) -> B,
Takes a closure and creates an iterator which calls that closure on each element. Read more
fn for_each<F>(self, f: F) where
F: FnMut(Self::Item),
1.21.0[src]
fn for_each<F>(self, f: F) where
F: FnMut(Self::Item),
Calls a closure on each element of an iterator. Read more
fn filter<P>(self, predicate: P) -> Filter<Self, P> where
P: FnMut(&Self::Item) -> bool,
1.0.0[src]
fn filter<P>(self, predicate: P) -> Filter<Self, P> where
P: FnMut(&Self::Item) -> bool,
Creates an iterator which uses a closure to determine if an element should be yielded. Read more
fn filter_map<B, F>(self, f: F) -> FilterMap<Self, F> where
F: FnMut(Self::Item) -> Option<B>,
1.0.0[src]
fn filter_map<B, F>(self, f: F) -> FilterMap<Self, F> where
F: FnMut(Self::Item) -> Option<B>,
Creates an iterator that both filters and maps. Read more
fn enumerate(self) -> Enumerate<Self>
1.0.0[src]
fn enumerate(self) -> Enumerate<Self>
Creates an iterator which gives the current iteration count as well as the next value. Read more
fn peekable(self) -> Peekable<Self>
1.0.0[src]
fn peekable(self) -> Peekable<Self>
Creates an iterator which can use peek
to look at the next element of the iterator without consuming it. Read more
fn skip_while<P>(self, predicate: P) -> SkipWhile<Self, P> where
P: FnMut(&Self::Item) -> bool,
1.0.0[src]
fn skip_while<P>(self, predicate: P) -> SkipWhile<Self, P> where
P: FnMut(&Self::Item) -> bool,
Creates an iterator that [skip
]s elements based on a predicate. Read more
fn take_while<P>(self, predicate: P) -> TakeWhile<Self, P> where
P: FnMut(&Self::Item) -> bool,
1.0.0[src]
fn take_while<P>(self, predicate: P) -> TakeWhile<Self, P> where
P: FnMut(&Self::Item) -> bool,
Creates an iterator that yields elements based on a predicate. Read more
fn skip(self, n: usize) -> Skip<Self>
1.0.0[src]
fn skip(self, n: usize) -> Skip<Self>
Creates an iterator that skips the first n
elements. Read more
fn take(self, n: usize) -> Take<Self>
1.0.0[src]
fn take(self, n: usize) -> Take<Self>
Creates an iterator that yields its first n
elements. Read more
fn scan<St, B, F>(self, initial_state: St, f: F) -> Scan<Self, St, F> where
F: FnMut(&mut St, Self::Item) -> Option<B>,
1.0.0[src]
fn scan<St, B, F>(self, initial_state: St, f: F) -> Scan<Self, St, F> where
F: FnMut(&mut St, Self::Item) -> Option<B>,
An iterator adaptor similar to [fold
] that holds internal state and produces a new iterator. Read more
fn flat_map<U, F>(self, f: F) -> FlatMap<Self, U, F> where
F: FnMut(Self::Item) -> U,
U: IntoIterator,
1.0.0[src]
fn flat_map<U, F>(self, f: F) -> FlatMap<Self, U, F> where
F: FnMut(Self::Item) -> U,
U: IntoIterator,
Creates an iterator that works like map, but flattens nested structure. Read more
fn flatten(self) -> Flatten<Self> where
Self::Item: IntoIterator,
1.29.0[src]
fn flatten(self) -> Flatten<Self> where
Self::Item: IntoIterator,
Creates an iterator that flattens nested structure. Read more
fn fuse(self) -> Fuse<Self>
1.0.0[src]
fn fuse(self) -> Fuse<Self>
Creates an iterator which ends after the first [None
]. Read more
fn inspect<F>(self, f: F) -> Inspect<Self, F> where
F: FnMut(&Self::Item),
1.0.0[src]
fn inspect<F>(self, f: F) -> Inspect<Self, F> where
F: FnMut(&Self::Item),
Do something with each element of an iterator, passing the value on. Read more
fn by_ref(&mut self) -> &mut Self
1.0.0[src]
fn by_ref(&mut self) -> &mut Self
Borrows an iterator, rather than consuming it. Read more
#[must_use = "if you really need to exhaust the iterator, consider `.for_each(drop)` instead"]
fn collect<B>(self) -> B where
B: FromIterator<Self::Item>,
1.0.0[src]
#[must_use = "if you really need to exhaust the iterator, consider `.for_each(drop)` instead"]
fn collect<B>(self) -> B where
B: FromIterator<Self::Item>,
Transforms an iterator into a collection. Read more
fn partition<B, F>(self, f: F) -> (B, B) where
B: Default + Extend<Self::Item>,
F: FnMut(&Self::Item) -> bool,
1.0.0[src]
fn partition<B, F>(self, f: F) -> (B, B) where
B: Default + Extend<Self::Item>,
F: FnMut(&Self::Item) -> bool,
Consumes an iterator, creating two collections from it. Read more
fn try_fold<B, F, R>(&mut self, init: B, f: F) -> R where
F: FnMut(B, Self::Item) -> R,
R: Try<Ok = B>,
1.27.0[src]
fn try_fold<B, F, R>(&mut self, init: B, f: F) -> R where
F: FnMut(B, Self::Item) -> R,
R: Try<Ok = B>,
An iterator method that applies a function as long as it returns successfully, producing a single, final value. Read more
fn try_for_each<F, R>(&mut self, f: F) -> R where
F: FnMut(Self::Item) -> R,
R: Try<Ok = ()>,
1.27.0[src]
fn try_for_each<F, R>(&mut self, f: F) -> R where
F: FnMut(Self::Item) -> R,
R: Try<Ok = ()>,
An iterator method that applies a fallible function to each item in the iterator, stopping at the first error and returning that error. Read more
fn fold<B, F>(self, init: B, f: F) -> B where
F: FnMut(B, Self::Item) -> B,
1.0.0[src]
fn fold<B, F>(self, init: B, f: F) -> B where
F: FnMut(B, Self::Item) -> B,
An iterator method that applies a function, producing a single, final value. Read more
fn all<F>(&mut self, f: F) -> bool where
F: FnMut(Self::Item) -> bool,
1.0.0[src]
fn all<F>(&mut self, f: F) -> bool where
F: FnMut(Self::Item) -> bool,
Tests if every element of the iterator matches a predicate. Read more
fn any<F>(&mut self, f: F) -> bool where
F: FnMut(Self::Item) -> bool,
1.0.0[src]
fn any<F>(&mut self, f: F) -> bool where
F: FnMut(Self::Item) -> bool,
Tests if any element of the iterator matches a predicate. Read more
fn find<P>(&mut self, predicate: P) -> Option<Self::Item> where
P: FnMut(&Self::Item) -> bool,
1.0.0[src]
fn find<P>(&mut self, predicate: P) -> Option<Self::Item> where
P: FnMut(&Self::Item) -> bool,
Searches for an element of an iterator that satisfies a predicate. Read more
fn find_map<B, F>(&mut self, f: F) -> Option<B> where
F: FnMut(Self::Item) -> Option<B>,
1.30.0[src]
fn find_map<B, F>(&mut self, f: F) -> Option<B> where
F: FnMut(Self::Item) -> Option<B>,
Applies function to the elements of iterator and returns the first non-none result. Read more
fn position<P>(&mut self, predicate: P) -> Option<usize> where
P: FnMut(Self::Item) -> bool,
1.0.0[src]
fn position<P>(&mut self, predicate: P) -> Option<usize> where
P: FnMut(Self::Item) -> bool,
Searches for an element in an iterator, returning its index. Read more
fn rposition<P>(&mut self, predicate: P) -> Option<usize> where
P: FnMut(Self::Item) -> bool,
Self: ExactSizeIterator + DoubleEndedIterator,
1.0.0[src]
fn rposition<P>(&mut self, predicate: P) -> Option<usize> where
P: FnMut(Self::Item) -> bool,
Self: ExactSizeIterator + DoubleEndedIterator,
Searches for an element in an iterator from the right, returning its index. Read more
fn max(self) -> Option<Self::Item> where
Self::Item: Ord,
1.0.0[src]
fn max(self) -> Option<Self::Item> where
Self::Item: Ord,
Returns the maximum element of an iterator. Read more
fn min(self) -> Option<Self::Item> where
Self::Item: Ord,
1.0.0[src]
fn min(self) -> Option<Self::Item> where
Self::Item: Ord,
Returns the minimum element of an iterator. Read more
fn max_by_key<B, F>(self, f: F) -> Option<Self::Item> where
B: Ord,
F: FnMut(&Self::Item) -> B,
1.6.0[src]
fn max_by_key<B, F>(self, f: F) -> Option<Self::Item> where
B: Ord,
F: FnMut(&Self::Item) -> B,
Returns the element that gives the maximum value from the specified function. Read more
fn max_by<F>(self, compare: F) -> Option<Self::Item> where
F: FnMut(&Self::Item, &Self::Item) -> Ordering,
1.15.0[src]
fn max_by<F>(self, compare: F) -> Option<Self::Item> where
F: FnMut(&Self::Item, &Self::Item) -> Ordering,
Returns the element that gives the maximum value with respect to the specified comparison function. Read more
fn min_by_key<B, F>(self, f: F) -> Option<Self::Item> where
B: Ord,
F: FnMut(&Self::Item) -> B,
1.6.0[src]
fn min_by_key<B, F>(self, f: F) -> Option<Self::Item> where
B: Ord,
F: FnMut(&Self::Item) -> B,
Returns the element that gives the minimum value from the specified function. Read more
fn min_by<F>(self, compare: F) -> Option<Self::Item> where
F: FnMut(&Self::Item, &Self::Item) -> Ordering,
1.15.0[src]
fn min_by<F>(self, compare: F) -> Option<Self::Item> where
F: FnMut(&Self::Item, &Self::Item) -> Ordering,
Returns the element that gives the minimum value with respect to the specified comparison function. Read more
fn rev(self) -> Rev<Self> where
Self: DoubleEndedIterator,
1.0.0[src]
fn rev(self) -> Rev<Self> where
Self: DoubleEndedIterator,
Reverses an iterator's direction. Read more
fn unzip<A, B, FromA, FromB>(self) -> (FromA, FromB) where
FromA: Default + Extend<A>,
FromB: Default + Extend<B>,
Self: Iterator<Item = (A, B)>,
1.0.0[src]
fn unzip<A, B, FromA, FromB>(self) -> (FromA, FromB) where
FromA: Default + Extend<A>,
FromB: Default + Extend<B>,
Self: Iterator<Item = (A, B)>,
Converts an iterator of pairs into a pair of containers. Read more
fn cloned<'a, T>(self) -> Cloned<Self> where
Self: Iterator<Item = &'a T>,
T: 'a + Clone,
1.0.0[src]
fn cloned<'a, T>(self) -> Cloned<Self> where
Self: Iterator<Item = &'a T>,
T: 'a + Clone,
Creates an iterator which [clone
]s all of its elements. Read more
fn cycle(self) -> Cycle<Self> where
Self: Clone,
1.0.0[src]
fn cycle(self) -> Cycle<Self> where
Self: Clone,
Repeats an iterator endlessly. Read more
fn sum<S>(self) -> S where
S: Sum<Self::Item>,
1.11.0[src]
fn sum<S>(self) -> S where
S: Sum<Self::Item>,
Sums the elements of an iterator. Read more
fn product<P>(self) -> P where
P: Product<Self::Item>,
1.11.0[src]
fn product<P>(self) -> P where
P: Product<Self::Item>,
Iterates over the entire iterator, multiplying all the elements Read more
fn cmp<I>(self, other: I) -> Ordering where
I: IntoIterator<Item = Self::Item>,
Self::Item: Ord,
1.5.0[src]
fn cmp<I>(self, other: I) -> Ordering where
I: IntoIterator<Item = Self::Item>,
Self::Item: Ord,
Lexicographically compares the elements of this Iterator
with those of another. Read more
fn partial_cmp<I>(self, other: I) -> Option<Ordering> where
I: IntoIterator,
Self::Item: PartialOrd<<I as IntoIterator>::Item>,
1.5.0[src]
fn partial_cmp<I>(self, other: I) -> Option<Ordering> where
I: IntoIterator,
Self::Item: PartialOrd<<I as IntoIterator>::Item>,
Lexicographically compares the elements of this Iterator
with those of another. Read more
fn eq<I>(self, other: I) -> bool where
I: IntoIterator,
Self::Item: PartialEq<<I as IntoIterator>::Item>,
1.5.0[src]
fn eq<I>(self, other: I) -> bool where
I: IntoIterator,
Self::Item: PartialEq<<I as IntoIterator>::Item>,
Determines if the elements of this Iterator
are equal to those of another. Read more
fn ne<I>(self, other: I) -> bool where
I: IntoIterator,
Self::Item: PartialEq<<I as IntoIterator>::Item>,
1.5.0[src]
fn ne<I>(self, other: I) -> bool where
I: IntoIterator,
Self::Item: PartialEq<<I as IntoIterator>::Item>,
Determines if the elements of this Iterator
are unequal to those of another. Read more
fn lt<I>(self, other: I) -> bool where
I: IntoIterator,
Self::Item: PartialOrd<<I as IntoIterator>::Item>,
1.5.0[src]
fn lt<I>(self, other: I) -> bool where
I: IntoIterator,
Self::Item: PartialOrd<<I as IntoIterator>::Item>,
Determines if the elements of this Iterator
are lexicographically less than those of another. Read more
fn le<I>(self, other: I) -> bool where
I: IntoIterator,
Self::Item: PartialOrd<<I as IntoIterator>::Item>,
1.5.0[src]
fn le<I>(self, other: I) -> bool where
I: IntoIterator,
Self::Item: PartialOrd<<I as IntoIterator>::Item>,
Determines if the elements of this Iterator
are lexicographically less or equal to those of another. Read more
fn gt<I>(self, other: I) -> bool where
I: IntoIterator,
Self::Item: PartialOrd<<I as IntoIterator>::Item>,
1.5.0[src]
fn gt<I>(self, other: I) -> bool where
I: IntoIterator,
Self::Item: PartialOrd<<I as IntoIterator>::Item>,
Determines if the elements of this Iterator
are lexicographically greater than those of another. Read more
fn ge<I>(self, other: I) -> bool where
I: IntoIterator,
Self::Item: PartialOrd<<I as IntoIterator>::Item>,
1.5.0[src]
fn ge<I>(self, other: I) -> bool where
I: IntoIterator,
Self::Item: PartialOrd<<I as IntoIterator>::Item>,
Determines if the elements of this Iterator
are lexicographically greater than or equal to those of another. Read more
Auto Trait Implementations
impl<S, L> Send for WsServer<S, L> where
L: Send,
S: Send,
impl<S, L> Send for WsServer<S, L> where
L: Send,
S: Send,
impl<S, L> Sync for WsServer<S, L> where
L: Sync,
S: Sync,
impl<S, L> Sync for WsServer<S, L> where
L: Sync,
S: Sync,
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
impl<T, U> Into for T where
U: From<T>,
impl<T> From for T
[src]
impl<T> From for T
impl<I> IntoIterator for I where
I: Iterator,
[src]
impl<I> IntoIterator for I where
I: Iterator,
type Item = <I as Iterator>::Item
The type of the elements being iterated over.
type IntoIter = I
Which kind of iterator are we turning this into?
fn into_iter(self) -> I
[src]
fn into_iter(self) -> I
Creates an iterator from a value. Read more
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>
try_from
)Performs the conversion.
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
Mutably borrows from an owned value. Read more
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>
try_from
)Performs the conversion.
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
🔬 This is a nightly-only experimental API. (get_type_id
)
this method will likely be replaced by an associated static
Gets the TypeId
of self
. Read more
impl<T> Typeable for T where
T: Any,
[src]
impl<T> Typeable for T where
T: Any,
impl<I> UnicodeNormalization for I where
I: Iterator<Item = char>,
[src]
impl<I> UnicodeNormalization for I where
I: Iterator<Item = char>,
fn nfd(self) -> Decompositions<I>
[src]
fn nfd(self) -> Decompositions<I>
Returns an iterator over the string in Unicode Normalization Form D (canonical decomposition). Read more
fn nfkd(self) -> Decompositions<I>
[src]
fn nfkd(self) -> Decompositions<I>
Returns an iterator over the string in Unicode Normalization Form KD (compatibility decomposition). Read more
fn nfc(self) -> Recompositions<I>
[src]
fn nfc(self) -> Recompositions<I>
An Iterator over the string in Unicode Normalization Form C (canonical decomposition followed by canonical composition). Read more
fn nfkc(self) -> Recompositions<I>
[src]
fn nfkc(self) -> Recompositions<I>
An Iterator over the string in Unicode Normalization Form KC (compatibility decomposition followed by canonical composition). Read more
fn stream_safe(self) -> StreamSafe<I>
[src]
fn stream_safe(self) -> StreamSafe<I>
An Iterator over the string with Conjoining Grapheme Joiner characters inserted according to the Stream-Safe Text Process (UAX15-D4) Read more
impl<T> Erased for T
[src]
impl<T> Erased for T