mirror of
https://github.com/hexedtech/codemp-nvim.git
synced 2024-11-22 15:34:53 +01:00
chore: split cursor and buffer protos
This commit is contained in:
parent
8595d0c927
commit
9a1d84bc64
4 changed files with 37 additions and 19 deletions
1
build.rs
1
build.rs
|
@ -1,4 +1,5 @@
|
||||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
tonic_build::compile_protos("proto/buffer.proto")?;
|
tonic_build::compile_protos("proto/buffer.proto")?;
|
||||||
|
tonic_build::compile_protos("proto/cursor.proto")?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,26 +1,16 @@
|
||||||
syntax = "proto3";
|
syntax = "proto3";
|
||||||
package buffer;
|
|
||||||
|
package codemp.buffer;
|
||||||
|
|
||||||
service Buffer {
|
service Buffer {
|
||||||
rpc Attach (BufferPayload) returns (stream RawOp);
|
rpc Attach (BufferPayload) returns (stream RawOp);
|
||||||
rpc Edit (OperationRequest) returns (BufferResponse);
|
rpc Edit (OperationRequest) returns (BufferEditResponse);
|
||||||
rpc Create (BufferPayload) returns (BufferResponse);
|
rpc Create (BufferPayload) returns (BufferCreateResponse);
|
||||||
rpc Sync (BufferPayload) returns (BufferResponse);
|
rpc Sync (BufferPayload) returns (BufferResponse);
|
||||||
rpc Moved (Cursor) returns (BufferResponse);
|
|
||||||
rpc Listen (BufferPayload) returns (stream Cursor);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
message Position {
|
message BufferCreateResponse {}
|
||||||
int32 row = 1;
|
message BufferEditResponse {}
|
||||||
int32 col = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
message Cursor {
|
|
||||||
string user = 1;
|
|
||||||
string buffer = 2;
|
|
||||||
Position start = 3;
|
|
||||||
Position end = 4;
|
|
||||||
}
|
|
||||||
|
|
||||||
message RawOp {
|
message RawOp {
|
||||||
string opseq = 1;
|
string opseq = 1;
|
||||||
|
@ -41,6 +31,5 @@ message BufferPayload {
|
||||||
}
|
}
|
||||||
|
|
||||||
message BufferResponse {
|
message BufferResponse {
|
||||||
bool accepted = 1;
|
string content = 2;
|
||||||
optional string content = 2;
|
|
||||||
}
|
}
|
||||||
|
|
26
proto/cursor.proto
Normal file
26
proto/cursor.proto
Normal 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;
|
||||||
|
}
|
|
@ -9,8 +9,10 @@ pub use tokio;
|
||||||
pub use operational_transform as ot;
|
pub use operational_transform as ot;
|
||||||
|
|
||||||
#[cfg(feature = "proto")]
|
#[cfg(feature = "proto")]
|
||||||
|
#[allow(non_snake_case)]
|
||||||
pub mod proto {
|
pub mod proto {
|
||||||
tonic::include_proto!("buffer");
|
tonic::include_proto!("codemp.buffer");
|
||||||
|
tonic::include_proto!("codemp.cursor");
|
||||||
}
|
}
|
||||||
|
|
||||||
pub use errors::CodempError;
|
pub use errors::CodempError;
|
||||||
|
|
Loading…
Reference in a new issue