dartboard-core 0.1.4

Core canvas model, color types, client traits, and wire protocol for dartboard
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use crate::ops::CanvasOp;
use crate::wire::{ClientOpId, ServerMsg};

/// A Client is a handle to a dartboard session. It submits ops to the server
/// and drains server events. Implementations: LocalClient (in-proc, in
/// dartboard-local) and WebsocketClient (cross-process, in dartboard-client-ws).
pub trait Client {
    /// Submit an op to the server. Returns the client_op_id the op was tagged
    /// with (monotonic per client), which will be echoed back in the matching
    /// Ack or Reject.
    fn submit_op(&mut self, op: CanvasOp) -> ClientOpId;

    /// Non-blocking event drain. Returns None if no events are pending.
    fn try_recv(&mut self) -> Option<ServerMsg>;
}