Struct Client

Source
pub struct Client<L = RpcLogger<RpcService>> { /* private fields */ }
Available on crate features async-client and async-wasm-client and client only.
Expand description

Generic asynchronous client.

Implementations§

Source§

impl Client<Identity>

Source

pub fn builder() -> ClientBuilder

Create a builder for the client.

Source§

impl<L> Client<L>

Source

pub fn is_connected(&self) -> bool

Checks if the client is connected to the target.

Source

pub async fn on_disconnect(&self) -> Error

Completes when the client is disconnected or the client’s background task encountered an error. If the client is already disconnected, the future produced by this method will complete immediately.

§Cancel safety

This method is cancel safe.

Source

pub fn request_timeout(&self) -> Duration

Returns configured request timeout.

Trait Implementations§

Source§

impl<L> ClientT for Client<L>
where L: RpcServiceT<MethodResponse = Result<MiddlewareMethodResponse, Error>, BatchResponse = Result<MiddlewareBatchResponse, Error>, NotificationResponse = Result<MiddlewareNotifResponse, Error>> + Send + Sync,

Source§

fn notification<Params>( &self, method: &str, params: Params, ) -> impl Future<Output = Result<(), Error>> + Send
where Params: ToRpcParams + Send,

Source§

fn request<R, Params>( &self, method: &str, params: Params, ) -> impl Future<Output = Result<R, Error>> + Send
where R: DeserializeOwned, Params: ToRpcParams + Send,

Source§

fn batch_request<'a, R>( &self, batch: BatchRequestBuilder<'a>, ) -> impl Future<Output = Result<BatchResponse<'a, R>, Error>> + Send
where R: DeserializeOwned + 'a,

Source§

impl<L: Debug> Debug for Client<L>

Source§

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

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

impl<L> Drop for Client<L>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<L> SubscriptionClientT for Client<L>
where L: RpcServiceT<MethodResponse = Result<MiddlewareMethodResponse, Error>, BatchResponse = Result<MiddlewareBatchResponse, Error>, NotificationResponse = Result<MiddlewareNotifResponse, Error>> + Send + Sync,

Source§

fn subscribe<'a, Notif, Params>( &self, subscribe_method: &'a str, params: Params, unsubscribe_method: &'a str, ) -> impl Future<Output = Result<Subscription<Notif>, Error>> + Send
where Params: ToRpcParams + Send, Notif: DeserializeOwned,

Send a subscription request to the server.

The subscribe_method and params are used to ask for the subscription towards the server. The unsubscribe_method is used to close the subscription.

Source§

fn subscribe_to_method<N>( &self, method: &str, ) -> impl Future<Output = Result<Subscription<N>, Error>> + Send

Subscribe to a specific method.

Auto Trait Implementations§

§

impl<L = RpcLogger<RpcService>> !Freeze for Client<L>

§

impl<L = RpcLogger<RpcService>> !RefUnwindSafe for Client<L>

§

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

§

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

§

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

§

impl<L = RpcLogger<RpcService>> !UnwindSafe for Client<L>

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

impl<T> MaybeSend for T
where T: Send,