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) -> Selfwhere
S: Send + Sync + Stream<Item = Result<Message, Error>> + Sink<Message, Error = Error> + Unpin,
pub fn new<S: 'static>(ws: S) -> Selfwhere
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 Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
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