alloy_rpc_client

Struct ClientBuilder

source
pub struct ClientBuilder<L> { /* private fields */ }
Expand description

A builder for the transport RpcClient.

This is a wrapper around tower::ServiceBuilder. It allows you to configure middleware layers that will be applied to the transport, and has some shortcuts for common layers and transports.

A builder accumulates Layers, and then is finished via the ClientBuilder::connect method, which produces an RPC client.

Implementations§

source§

impl<L> ClientBuilder<L>

source

pub fn layer<M>(self, layer: M) -> ClientBuilder<Stack<M, L>>

Add a middleware layer to the stack.

This is a wrapper around tower::ServiceBuilder::layer. Layers that are added first will be called with the request first.

source

pub fn transport<T>(self, transport: T, is_local: bool) -> RpcClient<L::Service>
where L: Layer<T>, T: Transport, L::Service: Transport,

Create a new RpcClient with the given transport and the configured layers.

source

pub fn http(self, url: Url) -> RpcClient<L::Service>
where L: Layer<Http<Client>>, L::Service: Transport,

Available on crate feature reqwest only.

Convenience function to create a new RpcClient with a reqwest HTTP transport.

source

pub fn hyper_http(self, url: Url) -> RpcClient<L::Service>

Available on non-WebAssembly and crate feature hyper only.

Convenience function to create a new RpcClient with a hyper HTTP transport.

source

pub async fn pubsub<C>( self, pubsub_connect: C, ) -> TransportResult<RpcClient<L::Service>>

Available on crate feature pubsub only.

Connect a pubsub transport, producing an RpcClient with the provided connection.

source

pub async fn ws( self, ws_connect: WsConnect, ) -> TransportResult<RpcClient<L::Service>>

Available on crate feature ws only.

Connect a WS transport, producing an RpcClient with the provided connection

source

pub async fn ipc<T>( self, ipc_connect: IpcConnect<T>, ) -> TransportResult<RpcClient<L::Service>>

Available on crate feature ipc only.

Connect an IPC transport, producing an RpcClient with the provided connection.

source

pub async fn connect<C>( self, connect: C, ) -> TransportResult<RpcClient<L::Service>>

Connect a transport, producing an RpcClient with the provided connection.

source

pub async fn connect_boxed<C>( self, connect: C, ) -> TransportResult<RpcClient<L::Service>>

Connect a transport, producing an RpcClient with a BoxTransport connection.

Trait Implementations§

source§

impl<L: Debug> Debug for ClientBuilder<L>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for ClientBuilder<Identity>

source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<L> Freeze for ClientBuilder<L>
where L: Freeze,

§

impl<L> RefUnwindSafe for ClientBuilder<L>
where L: RefUnwindSafe,

§

impl<L> Send for ClientBuilder<L>
where L: Send,

§

impl<L> Sync for ClientBuilder<L>
where L: Sync,

§

impl<L> Unpin for ClientBuilder<L>
where L: Unpin,

§

impl<L> UnwindSafe for ClientBuilder<L>
where L: UnwindSafe,

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> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more