pub struct Client {
pub incoming: Receiver<String>,
pub outgoing: Sender<Command>,
/* private fields */
}Expand description
A higher-level client wrapper that provides incoming/outgoing channels and a graceful shutdown handle for the background connection task.
Fields§
§incoming: Receiver<String>Incoming lines received from the server.
outgoing: Sender<Command>Send Command values to be written to the server.
Implementations§
Source§impl Client
impl Client
Sourcepub fn start(addr: String, api_key: String) -> Self
pub fn start(addr: String, api_key: String) -> Self
Spawn a background task to maintain a long-lived connection to addr.
Returns a Client that can send commands and receive incoming lines.
Sourcepub async fn send(&self, cmd: Command) -> Result<(), SendError<Command>>
pub async fn send(&self, cmd: Command) -> Result<(), SendError<Command>>
Asynchronously send a Command to the server via the background task.
Trait Implementations§
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