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

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 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 mutliple 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

§

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

The output that the future will produce on completion.
§

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

§

type Output = T

Should always be Self
source§

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

§

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>,

§

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