chore: back from transport to proto

This commit is contained in:
əlemi 2024-02-09 00:39:07 +01:00
parent 45c1106d98
commit 47127bbb41
5 changed files with 14 additions and 16 deletions

View file

@ -31,9 +31,9 @@ postcard = { version = "1.0.8", optional = true }
tonic-build = "0.9" tonic-build = "0.9"
[features] [features]
default = [] default = []
api = ["woot", "dep:tokio", "dep:async-trait"] api = ["woot", "dep:tokio", "dep:async-trait"]
woot = ["dep:codemp-woot", "dep:similar"] woot = ["dep:codemp-woot", "dep:similar"]
transport = ["dep:prost", "dep:tonic", "dep:uuid"] proto = ["dep:prost", "dep:tonic", "dep:uuid"]
client = ["transport", "api", "dep:tokio", "dep:tokio-stream", "dep:uuid", "dep:md5", "dep:serde_json", "dep:dashmap", "dep:postcard"] client = ["proto", "api", "dep:tokio", "dep:tokio-stream", "dep:uuid", "dep:md5", "dep:serde_json", "dep:dashmap", "dep:postcard"]
server = ["transport", "woot"] server = ["proto", "woot"]

View file

@ -2,7 +2,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
tonic_build::configure() tonic_build::configure()
// .build_client(cfg!(feature = "client")) // .build_client(cfg!(feature = "client"))
// .build_server(cfg!(feature = "server")) // FIXME if false, build fails???? // .build_server(cfg!(feature = "server")) // FIXME if false, build fails????
// .build_transport(cfg!(feature = "transport")) // .build_transport(cfg!(feature = "proto"))
.compile( .compile(
&[ &[
"proto/common.proto", "proto/common.proto",

View file

@ -112,7 +112,7 @@ impl TextChange {
/// convert from byte index to row and column /// convert from byte index to row and column
/// txt must be the whole content of the buffer, in order to count lines /// txt must be the whole content of the buffer, in order to count lines
#[cfg(feature = "transport")] #[cfg(feature = "proto")]
pub fn index_to_rowcol(txt: &str, index: usize) -> crate::proto::cursor::RowCol { pub fn index_to_rowcol(txt: &str, index: usize) -> crate::proto::cursor::RowCol {
// FIXME might panic, use .get() // FIXME might panic, use .get()
let row = txt[..index].matches('\n').count() as i32; let row = txt[..index].matches('\n').count() as i32;

View file

@ -21,12 +21,10 @@
//! immediately but instead deferred until compatible. //! immediately but instead deferred until compatible.
//! //!
//! ## features //! ## features
//! * `woot` : include the underlying CRDT library and re-exports it (default enabled) //! * `woot` : include the underlying CRDT library and re-exports it (default enabled)
//! * `api` : include traits for core interfaces under [api] (default enabled) //! * `api` : include traits for core interfaces under [api] (default enabled)
//! * `proto` : include GRCP protocol definitions under [proto] (default enabled) //! * `proto` : include GRCP protocol definitions under [proto] (default enabled)
//! * `client`: include the local [client] implementation (default enabled) //! * `client` : include the local [client] implementation (default enabled)
//! * `global`: provide a lazy_static global INSTANCE in [instance::global]
//! * `sync` : wraps the [instance::a_sync::Instance] holder into a sync variant: [instance::sync::Instance]
//! //!
//! ## examples //! ## examples
//! while the [client::Client] itself is the core structure implementing all methods, plugins will mostly //! while the [client::Client] itself is the core structure implementing all methods, plugins will mostly
@ -160,7 +158,7 @@ pub mod prelude;
pub use woot; pub use woot;
/// protocol types and services auto-generated by grpc /// protocol types and services auto-generated by grpc
#[cfg(feature = "transport")] #[cfg(feature = "proto")]
#[allow(non_snake_case)] #[allow(non_snake_case)]
pub mod proto { pub mod proto {
pub mod common { pub mod common {

View file

@ -26,7 +26,7 @@ pub use crate::{
buffer::Controller as CodempBufferController, buffer::Controller as CodempBufferController,
}; };
#[cfg(feature = "transport")] #[cfg(feature = "proto")]
pub use crate::{ pub use crate::{
proto::cursor::CursorPosition as CodempCursorPosition, proto::cursor::CursorPosition as CodempCursorPosition,
proto::cursor::CursorEvent as CodempCursorEvent, proto::cursor::CursorEvent as CodempCursorEvent,