pub struct Connection { /* private fields */ }Expand description
A live connection to a plugin.
Implementations§
Source§impl Connection
impl Connection
Sourcepub fn new<R, W>(reader: R, writer: W, max_message_bytes: usize) -> Self
pub fn new<R, W>(reader: R, writer: W, max_message_bytes: usize) -> Self
Connect over a reader/writer pair. Must be called inside a tokio runtime.
Sourcepub fn is_closed(&self) -> bool
pub fn is_closed(&self) -> bool
Whether the connection is closed (the plugin exited or broke the protocol).
Sourcepub fn recent_logs(&self) -> Vec<String>
pub fn recent_logs(&self) -> Vec<String>
Recent log notifications from the plugin (level: message).
Sourcepub fn set_label(&self, label: &str)
pub fn set_label(&self, label: &str)
Name used when forwarding the plugin’s log lines to the operator.
Sourcepub fn close(&self, reason: &str)
pub fn close(&self, reason: &str)
Close the connection (pending requests fail with reason) and drop the
guarded resource on the next drop of this connection.
Sourcepub async fn call(
&self,
id: String,
method: &str,
params: Value,
sink: Option<NotifySink>,
cancel_on_drop: bool,
) -> Result<Value, CallError>
pub async fn call( &self, id: String, method: &str, params: Value, sink: Option<NotifySink>, cancel_on_drop: bool, ) -> Result<Value, CallError>
Send a request with id id and wait for its response. Notifications whose
request_id equals id go to sink. When the returned future is dropped
before completion and cancel_on_drop is set, a node.cancel notification
is sent.
Trait Implementations§
Source§impl Debug for Connection
impl Debug for Connection
Source§impl Drop for Connection
impl Drop for Connection
Auto Trait Implementations§
impl !Freeze for Connection
impl !RefUnwindSafe for Connection
impl !UnwindSafe for Connection
impl Forget for Connection
impl Move for Connection
impl Send for Connection
impl Sync for Connection
impl Unpin for Connection
impl UnsafeUnpin 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