pub struct Connection { /* private fields */ }Expand description
Cloneable request handle for one MSP transport.
Connection::new also returns a ConnectionDriver. The caller drives
that future on its own executor; this crate never creates or blocks an async
runtime.
Implementations§
Source§impl Connection
impl Connection
Sourcepub fn new<T>(transport: T) -> (Self, ConnectionDriver<T>)where
T: DuplexTransport,
pub fn new<T>(transport: T) -> (Self, ConnectionDriver<T>)where
T: DuplexTransport,
Builds a request handle and its caller-driven transport loop.
Sourcepub async fn request(
&self,
method: impl Into<String>,
params: Option<Map<String, Value>>,
) -> Result<Map<String, Value>, ConnectionError>
pub async fn request( &self, method: impl Into<String>, params: Option<Map<String, Value>>, ) -> Result<Map<String, Value>, ConnectionError>
Sends one request and waits for the response carrying the same id.
A successful transport write means only that the frame was submitted. This future remains pending until the matching result or error arrives.
Sourcepub async fn notify(
&self,
method: impl Into<String>,
params: Option<Map<String, Value>>,
) -> Result<(), ConnectionError>
pub async fn notify( &self, method: impl Into<String>, params: Option<Map<String, Value>>, ) -> Result<(), ConnectionError>
Submits one fire-and-forget notification to the transport.
Sourcepub fn subscribe_notifications(&self) -> Receiver<Notification>
pub fn subscribe_notifications(&self) -> Receiver<Notification>
Subscribes to server notifications received after subscription.
Sourcepub fn subscribe_protocol_errors(&self) -> Receiver<ProtocolError>
pub fn subscribe_protocol_errors(&self) -> Receiver<ProtocolError>
Subscribes to non-fatal framing and correlation errors.
Trait Implementations§
Source§impl Clone for Connection
impl Clone for Connection
Source§impl HandshakeConnection for Connection
impl HandshakeConnection for Connection
Auto Trait Implementations§
impl Freeze for Connection
impl RefUnwindSafe for Connection
impl Send for Connection
impl Sync for Connection
impl Unpin for Connection
impl UnsafeUnpin for Connection
impl UnwindSafe for Connection
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