Struct ethers_providers::legacy_ws::Ws
source · 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
§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
§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 !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