Struct ethers_providers::Ws
source · [−]pub struct Ws { /* private fields */ }Expand description
A JSON-RPC Client over Websockets.
use ethers_providers::Ws;
let ws = Ws::connect("wss://localhost:8545").await?;Implementations
sourceimpl Ws
impl Ws
sourcepub fn new<S: 'static>(ws: S) -> Self where
S: Send + Sync + Stream<Item = Result<Message, Error>> + Sink<Message, Error = Error> + Unpin,
pub fn new<S: 'static>(ws: S) -> Self where
S: Send + Sync + Stream<Item = Result<Message, Error>> + Sink<Message, Error = Error> + Unpin,
Initializes a new WebSocket Client, given a Stream/Sink Websocket implementer. The websocket connection must be initiated separately.
sourcepub async fn connect(
url: impl IntoClientRequest + Unpin
) -> Result<Self, ClientError>
pub async fn connect(
url: impl IntoClientRequest + Unpin
) -> Result<Self, ClientError>
Initializes a new WebSocket Client
sourcepub async fn connect_with_auth(
uri: impl IntoClientRequest + Unpin,
auth: Authorization
) -> Result<Self, ClientError>
pub async fn connect_with_auth(
uri: impl IntoClientRequest + Unpin,
auth: Authorization
) -> Result<Self, ClientError>
Initializes a new WebSocket Client with authentication
Trait Implementations
sourceimpl JsonRpcClient for Ws
impl JsonRpcClient for Ws
type Error = ClientError
type Error = ClientError
A JSON-RPC Error
sourcefn request<'life0, 'life1, 'async_trait, T, R>(
&'life0 self,
method: &'life1 str,
params: T
) -> Pin<Box<dyn Future<Output = Result<R, ClientError>> + Send + 'async_trait>> where
T: 'async_trait + Serialize + Send + Sync,
R: 'async_trait + DeserializeOwned,
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn request<'life0, 'life1, 'async_trait, T, R>(
&'life0 self,
method: &'life1 str,
params: T
) -> Pin<Box<dyn Future<Output = Result<R, ClientError>> + Send + 'async_trait>> where
T: 'async_trait + Serialize + Send + Sync,
R: 'async_trait + DeserializeOwned,
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Sends a request with the provided JSON-RPC and parameters serialized as JSON
sourceimpl PubsubClient for Ws
impl PubsubClient for Ws
type NotificationStream = UnboundedReceiver<Box<RawValue, Global>>
type NotificationStream = UnboundedReceiver<Box<RawValue, Global>>
The type of stream this transport returns
sourcefn subscribe<T: Into<U256>>(
&self,
id: T
) -> Result<Self::NotificationStream, ClientError>
fn subscribe<T: Into<U256>>(
&self,
id: T
) -> Result<Self::NotificationStream, ClientError>
Add a subscription to this transport
sourcefn unsubscribe<T: Into<U256>>(&self, id: T) -> Result<(), ClientError>
fn unsubscribe<T: Into<U256>>(&self, id: T) -> Result<(), ClientError>
Remove a subscription from this transport
Auto Trait Implementations
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Instruments this type with the provided Span, returning an
Instrumented wrapper. Read more
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into)Uses borrowed data to replace owned data, usually by cloning. Read more
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
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
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber to this type, returning a
WithDispatch wrapper. Read more