[−][src]Struct webtonic_client::Client
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 eitherws://
orwss://
, depending wether encryption is used or not.
Returns
- A
Client
on success. WebTonicError::InvalidUrl
, if the url is malformed.WebTonicError::ConnectionError
, if the endpoint can not be reached.
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.
pub fn poll_ready(
&mut self,
_cx: &mut Context<'_>
) -> Poll<Result<(), Self::Error>>
[src]
&mut self,
_cx: &mut Context<'_>
) -> Poll<Result<(), Self::Error>>
pub fn call(&mut self, request: Request<BoxBody>) -> Self::Future
[src]
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> IntoRequest<T> for T
[src]
pub fn into_request(self) -> Request<T>
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,