diff --git a/build.rs b/build.rs index 838368e..8c727c0 100644 --- a/build.rs +++ b/build.rs @@ -1,4 +1,5 @@ fn main() -> Result<(), Box> { tonic_build::compile_protos("proto/buffer.proto")?; + tonic_build::compile_protos("proto/cursor.proto")?; Ok(()) } diff --git a/proto/buffer.proto b/proto/buffer.proto index 9b33b2e..b668a44 100644 --- a/proto/buffer.proto +++ b/proto/buffer.proto @@ -1,26 +1,16 @@ syntax = "proto3"; -package buffer; + +package codemp.buffer; service Buffer { rpc Attach (BufferPayload) returns (stream RawOp); - rpc Edit (OperationRequest) returns (BufferResponse); - rpc Create (BufferPayload) returns (BufferResponse); + rpc Edit (OperationRequest) returns (BufferEditResponse); + rpc Create (BufferPayload) returns (BufferCreateResponse); rpc Sync (BufferPayload) returns (BufferResponse); - rpc Moved (Cursor) returns (BufferResponse); - rpc Listen (BufferPayload) returns (stream Cursor); } -message Position { - int32 row = 1; - int32 col = 2; -} - -message Cursor { - string user = 1; - string buffer = 2; - Position start = 3; - Position end = 4; -} +message BufferCreateResponse {} +message BufferEditResponse {} message RawOp { string opseq = 1; @@ -41,6 +31,5 @@ message BufferPayload { } message BufferResponse { - bool accepted = 1; - optional string content = 2; + string content = 2; } diff --git a/proto/cursor.proto b/proto/cursor.proto new file mode 100644 index 0000000..39d40df --- /dev/null +++ b/proto/cursor.proto @@ -0,0 +1,26 @@ +syntax = "proto3"; + +package codemp.cursor; + +service Cursor { + rpc Moved (CursorPosition) returns (MovedResponse); + rpc Listen (UserIdentity) returns (stream CursorPosition); +} + +message MovedResponse {} + +message RowColumn { + int32 row = 1; + int32 col = 2; +} + +message CursorPosition { + string user = 1; + string buffer = 2; + RowColumn start = 3; + RowColumn end = 4; +} + +message UserIdentity { + string id = 1; +} diff --git a/src/lib.rs b/src/lib.rs index 132154c..bdd43d3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -9,8 +9,10 @@ pub use tokio; pub use operational_transform as ot; #[cfg(feature = "proto")] +#[allow(non_snake_case)] pub mod proto { - tonic::include_proto!("buffer"); + tonic::include_proto!("codemp.buffer"); + tonic::include_proto!("codemp.cursor"); } pub use errors::CodempError;