pub struct Client { /* private fields */ }Expand description
Connected client. One stream; notifications arriving during Self::request
are handed to the optional callback.
Implementations§
Source§impl Client
impl Client
Sourcepub fn connect(path: impl AsRef<Path>) -> Result<Self, Error>
pub fn connect(path: impl AsRef<Path>) -> Result<Self, Error>
Connect to path. Uses JSONL framing.
Sourcepub fn connect_with_framing(
path: impl AsRef<Path>,
framing: Framing,
) -> Result<Self, Error>
pub fn connect_with_framing( path: impl AsRef<Path>, framing: Framing, ) -> Result<Self, Error>
Connect and send every request in framing. The owner replies in kind.
pub fn framing(&self) -> Framing
Sourcepub fn on_notification<F>(&mut self, callback: F)
pub fn on_notification<F>(&mut self, callback: F)
Called for each JSON-RPC notification read while waiting on a response.
Sourcepub fn request(&mut self, method: &str, params: Value) -> Result<Value, Error>
pub fn request(&mut self, method: &str, params: Value) -> Result<Value, Error>
Send method/params and return the result object.
Sourcepub fn request_typed(&mut self, req: &Request) -> Result<Value, Error>
pub fn request_typed(&mut self, req: &Request) -> Result<Value, Error>
Typed request helper. Result is the raw JSON body (caller decodes).
Sourcepub fn notify(&mut self, method: &str, params: Value) -> Result<(), Error>
pub fn notify(&mut self, method: &str, params: Value) -> Result<(), Error>
Send a notification (no id). Does not wait.
Sourcepub fn wait_notification(
&mut self,
timeout: Duration,
) -> Result<Notification, Error>
pub fn wait_notification( &mut self, timeout: Duration, ) -> Result<Notification, Error>
Block until the next JSON-RPC notification, or timeout.
Auto Trait Implementations§
impl !RefUnwindSafe for Client
impl !Sync for Client
impl !UnwindSafe for Client
impl Freeze for Client
impl Send for Client
impl Unpin for Client
impl UnsafeUnpin 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