pub struct Client {
Sink: Arc<Mutex<SplitSink<WebSocketStream<MaybeTlsStream<TcpStream>>, Message>>>,
Pending: Arc<Mutex<HashMap<u64, Sender<Result<Value, String>>>>>,
NextIdentifier: AtomicU64,
Closed: AtomicBool,
}Expand description
Client-side connection. Holds the write half of the WebSocket and a map of pending requests keyed by id.
Fields§
§Sink: Arc<Mutex<SplitSink<WebSocketStream<MaybeTlsStream<TcpStream>>, Message>>>§Pending: Arc<Mutex<HashMap<u64, Sender<Result<Value, String>>>>>§NextIdentifier: AtomicU64§Closed: AtomicBoolImplementations§
Source§impl Client
impl Client
Sourcepub async fn connect(Address: &str) -> Result<Arc<Self>>
pub async fn connect(Address: &str) -> Result<Arc<Self>>
Connect to a Mist WebSocket server at Address
(e.g. ws://127.0.0.1:5051). Spawns a background reader
task that drains incoming frames and resolves pending
requests.
Sourcepub async fn invoke(&self, Method: &str, Params: Value) -> Result<Value, String>
pub async fn invoke(&self, Method: &str, Params: Value) -> Result<Value, String>
Invoke a remote method. Returns the result Value or an error
string. Pending requests are tracked by id; on disconnect the
future resolves with Err("connection closed").
Sourcepub async fn notify(&self, Method: &str, Params: Value) -> Result<(), String>
pub async fn notify(&self, Method: &str, Params: Value) -> Result<(), String>
Send a one-way notification (no response expected).
pub fn is_closed(&self) -> bool
Auto Trait Implementations§
impl !Freeze for Client
impl !RefUnwindSafe for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl UnsafeUnpin for Client
impl !UnwindSafe for Client
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more