[][src]Struct webtonic_client::Client

pub struct Client<'a> { /* fields omitted */ }

A websocket-tunneled, browser enabled tonic client.

This client can be used in place of tonic's Channel. It tunnels the request through a websocket connection to the server that reconstructs them and send them to their respective handlers.

Cryptography

This transport implementation does not directly support encryption. It is however possible to encrypt the websocket connection itself. However, client authentication is not possible that way.

Example

Assuming we have the greeter example in scope, we can instanciate a connection like so:

let client = Client::connect("ws://localhost:8080").await.unwrap();
let mut client = greeter_client::GreeterClient::new(client);

let request = tonic::Request::new(HelloRequest {
   name: "WebTonic".into(),
});

let response = client.say_hello(request).await.unwrap().into_inner();
assert_eq!(response.message, "Hello WebTonic!");

Implementations

impl Client<'static>[src]

pub async fn connect<'_>(uri: &'_ str) -> Result<Self, WebTonicError>[src]

Connects the client to the endpoint.

Arguments

  • uri: The uri to connect to. Note: The sceme is either ws:// or wss://, depending wether encryption is used or not.

Returns

Example

let client = Client::connect("ws://localhost:1337").await.unwrap();

Trait Implementations

impl<'a> Clone for Client<'a>[src]

impl<'a> Debug for Client<'a>[src]

impl<'a> GrpcService<BoxBody> for Client<'a>[src]

type ResponseBody = BoxBody

Responses body given by the service.

type Error = WebTonicError

Errors produced by the service.

type Future = LocalBoxFuture<'a, Result<Response<BoxBody>, WebTonicError>>

The future response value.

Auto Trait Implementations

impl<'a> !RefUnwindSafe for Client<'a>

impl<'a> !Send for Client<'a>

impl<'a> !Sync for Client<'a>

impl<'a> Unpin for Client<'a>

impl<'a> !UnwindSafe for Client<'a>

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> Instrument for T[src]

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

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

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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.