pub struct Ws { /* private fields */ }
Available on crate feature
legacy-ws
only.Expand description
A JSON-RPC Client over Websockets.
§Example
use ethers_providers::Ws;
let ws = Ws::connect("ws://localhost:8545").await?;
Implementations§
Source§impl Ws
impl Ws
Sourcepub fn new<S>(ws: S) -> Self
pub fn new<S>(ws: S) -> Self
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>
Available on non-WebAssembly only.
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>
Available on non-WebAssembly only.
pub async fn connect_with_auth( uri: impl IntoClientRequest + Unpin, auth: Authorization, ) -> Result<Self, ClientError>
Initializes a new WebSocket Client with authentication
Trait Implementations§
Source§impl JsonRpcClient for Ws
impl JsonRpcClient for Ws
Source§type Error = ClientError
type Error = ClientError
A JSON-RPC Error
Source§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,
Self: 'async_trait,
'life0: 'async_trait,
'life1: '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,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Sends a request with the provided JSON-RPC and parameters serialized as JSON
Source§impl PubsubClient for Ws
impl PubsubClient for Ws
Source§type NotificationStream = UnboundedReceiver<Box<RawValue>>
type NotificationStream = UnboundedReceiver<Box<RawValue>>
The type of stream this transport returns
Source§fn 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
Source§fn 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§
impl Freeze for Ws
impl !RefUnwindSafe for Ws
impl Send for Ws
impl Sync for Ws
impl Unpin for Ws
impl !UnwindSafe for Ws
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more