[][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

Blanket Implementations

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

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

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

impl<T> From<T> for T[src]

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

impl<T> Same<T> for T

type Output = T

Should always be Self

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,