Struct ClientBuilder

Source
pub struct ClientBuilder { /* private fields */ }
Expand description

Builder for Graphql over Websocket clients

This can be used to configure the client prior to construction, but can also create subscriptions directly in the case where users only need to run one per connection.

use graphql_ws_client::Client;
use std::future::IntoFuture;
let (client, actor) = Client::build(connection).await?;

Implementations§

Source§

impl ClientBuilder

Source

pub fn payload<NewPayload>( self, payload: NewPayload, ) -> Result<ClientBuilder, Error>
where NewPayload: Serialize,

Add payload to connection_init

§Errors

Will return Err if payload serialization fails.

Source

pub fn subscription_buffer_size(self, new: usize) -> Self

Sets the size of the incoming message buffer that subscriptions created by this client will use

Source

pub fn keep_alive_interval(self, new: Duration) -> Self

Sets the interval between keep alives.

Any incoming messages automatically reset this interval so keep alives may not be sent on busy connections even if this is set.

Source

pub fn keep_alive_retries(self, count: usize) -> Self

The number of keepalive retries before a connection is considered broken.

This defaults to 3, but has no effect if keep_alive_interval is not called.

Source

pub async fn subscribe<'a, Operation>( self, op: Operation, ) -> Result<Subscription<Operation>, Error>
where Operation: GraphqlOperation + Unpin + Send + 'static,

Initialise a Client and use it to run a single subscription

use graphql_ws_client::Client;
use std::future::IntoFuture;
let stream = Client::build(connection).subscribe(subscription).await?;

Note that this takes ownership of the client, so it cannot be used to run any more operations.

If users want to run multiple operations on a connection they should use the IntoFuture impl to construct a Client

Source§

impl ClientBuilder

Source

pub async fn build(self) -> Result<(Client, ConnectionActor), Error>

Constructs a Client

Accepts an already built websocket connection, and returns the connection and a future that must be awaited somewhere - if the future is dropped the connection will also drop.

Trait Implementations§

Source§

impl IntoFuture for ClientBuilder

Source§

type Output = Result<(Client, ConnectionActor), Error>

The output that the future will produce on completion.
Source§

type IntoFuture = Pin<Box<dyn Future<Output = <ClientBuilder as IntoFuture>::Output> + Send>>

Which kind of future are we turning this into?
Source§

fn into_future(self) -> Self::IntoFuture

Creates a future from a value. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

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

Source§

fn vzip(self) -> V

Source§

impl<T> IsFieldType<T> for T