chore: split cursor and buffer protos

This commit is contained in:
əlemi 2023-08-16 17:08:31 +02:00
parent 8595d0c927
commit 9a1d84bc64
4 changed files with 37 additions and 19 deletions

View file

@ -1,4 +1,5 @@
fn main() -> Result<(), Box<dyn std::error::Error>> {
tonic_build::compile_protos("proto/buffer.proto")?;
tonic_build::compile_protos("proto/cursor.proto")?;
Ok(())
}

View file

@ -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;
}

26
proto/cursor.proto Normal file
View file

@ -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;
}

View file

@ -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;