2023-04-17 14:56:00 +02:00
|
|
|
pub mod cursor;
|
2023-07-01 13:54:34 +02:00
|
|
|
pub mod errors;
|
2023-07-30 17:48:55 +02:00
|
|
|
pub mod buffer;
|
2023-04-07 03:05:21 +02:00
|
|
|
|
2023-08-16 18:58:42 +02:00
|
|
|
pub mod client;
|
2023-07-30 22:58:24 +02:00
|
|
|
|
2023-08-16 23:09:47 +02:00
|
|
|
#[cfg(feature = "static")]
|
|
|
|
pub mod instance;
|
|
|
|
|
2023-04-07 03:05:21 +02:00
|
|
|
pub use tonic;
|
|
|
|
pub use tokio;
|
2023-07-02 23:59:04 +02:00
|
|
|
pub use operational_transform as ot;
|
2023-07-01 13:54:34 +02:00
|
|
|
|
2023-07-30 22:58:24 +02:00
|
|
|
#[cfg(feature = "proto")]
|
2023-08-16 17:08:31 +02:00
|
|
|
#[allow(non_snake_case)]
|
2023-07-30 22:58:24 +02:00
|
|
|
pub mod proto {
|
2023-08-16 17:08:31 +02:00
|
|
|
tonic::include_proto!("codemp.buffer");
|
|
|
|
tonic::include_proto!("codemp.cursor");
|
2023-07-30 22:58:24 +02:00
|
|
|
}
|
2023-07-30 17:48:55 +02:00
|
|
|
|
2023-07-30 22:58:24 +02:00
|
|
|
pub use errors::CodempError;
|
|
|
|
|
|
|
|
#[tonic::async_trait] // TODO move this somewhere?
|
|
|
|
pub(crate) trait ControllerWorker<T> {
|
2023-08-16 18:58:42 +02:00
|
|
|
type Controller : Controller<T>;
|
|
|
|
type Tx;
|
|
|
|
type Rx;
|
|
|
|
|
|
|
|
fn subscribe(&self) -> Self::Controller;
|
|
|
|
async fn work(self, tx: Self::Tx, rx: Self::Rx);
|
2023-07-30 17:48:55 +02:00
|
|
|
}
|
|
|
|
|
2023-07-30 22:58:24 +02:00
|
|
|
#[tonic::async_trait]
|
|
|
|
pub trait Controller<T> {
|
2023-08-16 18:58:42 +02:00
|
|
|
type Input;
|
|
|
|
|
|
|
|
async fn send(&self, x: Self::Input) -> Result<(), CodempError>;
|
2023-07-30 22:58:24 +02:00
|
|
|
async fn recv(&self) -> Result<T, CodempError>;
|
2023-07-30 17:48:55 +02:00
|
|
|
}
|