[][src]Struct warp::test::WsBuilder

#[must_use = "WsBuilder does nothing on its own"]
pub struct WsBuilder { /* fields omitted */ }

A Websocket builder for testing filters.

See module documentation for an overview.

Methods

impl WsBuilder
[src]

pub fn path(self, p: &str) -> Self
[src]

Sets the request path of this builder.

The default is not set is /.

Example

let req = warp::test::ws()
    .path("/chat");

Panic

This panics if the passed string is not able to be parsed as a valid Uri.

pub fn header<K, V>(self, key: K, value: V) -> Self where
    HeaderName: HttpTryFrom<K>,
    HeaderValue: HttpTryFrom<V>, 
[src]

Set a header for this request.

Example

let req = warp::test::ws()
    .header("foo", "bar");

Panic

This panics if the passed strings are not able to be parsed as a valid HeaderName and HeaderValue.

pub fn handshake<F>(self, f: F) -> Result<WsClient, WsError> where
    F: Filter + Send + Sync + 'static,
    F::Extract: Reply + Send,
    F::Error: Reject + Send
[src]

Execute this Websocket request against te provided filter.

If the handshake succeeds, returns a WsClient.

Example

use futures::future;
use warp::Filter;

// Some route that accepts websockets (but drops them immediately).
let route = warp::ws2()
    .map(|ws: warp::ws::Ws2| {
        ws.on_upgrade(|_| future::ok(()))
    });

let client = warp::test::ws()
    .handshake(route)
    .expect("handshake");

Trait Implementations

impl Debug for WsBuilder
[src]

Auto Trait Implementations

impl Send for WsBuilder

impl !Sync for WsBuilder

Blanket Implementations

impl<T> From for T
[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom for T where
    T: From<U>, 
[src]

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Same for T

type Output = T

Should always be Self

impl<T> Erased for T