mirror of
https://github.com/hexedtech/codemp-proto.git
synced 2024-11-23 07:54:49 +01:00
chore: rustfmt & editorconfig
This commit is contained in:
parent
5ecd52d237
commit
4347dfa9d7
9 changed files with 60 additions and 34 deletions
20
.editorconfig
Normal file
20
.editorconfig
Normal file
|
@ -0,0 +1,20 @@
|
|||
# Default to Unix-style newlines with a newline ending every file
|
||||
[*]
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
charset = utf-8
|
||||
indent_style = tab
|
||||
indent_size = 4
|
||||
|
||||
[*.rs]
|
||||
indent_size = 2
|
||||
|
||||
[*.proto]
|
||||
indent_size = 2
|
||||
|
||||
[*.js]
|
||||
indent_size = 2
|
||||
|
||||
[*.{yml,yaml}]
|
||||
indent_style = space
|
||||
indent_size = 2
|
1
.rustfmt.toml
Normal file
1
.rustfmt.toml
Normal file
|
@ -0,0 +1 @@
|
|||
hard_tabs = true
|
26
build.rs
26
build.rs
|
@ -1,15 +1,13 @@
|
|||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
tonic_build::configure()
|
||||
.compile(
|
||||
&[
|
||||
"proto/common.proto",
|
||||
"proto/cursor.proto",
|
||||
"proto/files.proto",
|
||||
"proto/auth.proto",
|
||||
"proto/workspace.proto",
|
||||
"proto/buffer.proto",
|
||||
],
|
||||
&["proto"],
|
||||
)?;
|
||||
Ok(())
|
||||
}
|
||||
Ok(tonic_build::configure().compile(
|
||||
&[
|
||||
"proto/common.proto",
|
||||
"proto/cursor.proto",
|
||||
"proto/files.proto",
|
||||
"proto/auth.proto",
|
||||
"proto/workspace.proto",
|
||||
"proto/buffer.proto",
|
||||
],
|
||||
&["proto"],
|
||||
)?)
|
||||
}
|
||||
|
|
|
@ -4,8 +4,8 @@ package auth;
|
|||
|
||||
// authenticates users, issuing tokens
|
||||
service Auth {
|
||||
// send credentials and join a workspace, returns ready to use token
|
||||
rpc Login (WorkspaceJoinRequest) returns (Token);
|
||||
// send credentials and join a workspace, returns ready to use token
|
||||
rpc Login (WorkspaceJoinRequest) returns (Token);
|
||||
}
|
||||
|
||||
message Token {
|
||||
|
@ -14,7 +14,7 @@ message Token {
|
|||
|
||||
// TODO one-request-to-do-it-all from login to workspace access
|
||||
message WorkspaceJoinRequest {
|
||||
required string username = 1;
|
||||
required string password = 2;
|
||||
optional string workspace_id = 3;
|
||||
required string username = 1;
|
||||
required string password = 2;
|
||||
optional string workspace_id = 3;
|
||||
}
|
||||
|
|
|
@ -6,12 +6,12 @@ package buffer;
|
|||
|
||||
// handle buffer changes, keep in sync users
|
||||
service Buffer {
|
||||
// attach to a buffer and receive operations
|
||||
rpc Attach (stream Operation) returns (stream BufferEvent);
|
||||
// attach to a buffer and receive operations
|
||||
rpc Attach (stream Operation) returns (stream BufferEvent);
|
||||
}
|
||||
|
||||
message Operation {
|
||||
required bytes data = 1;
|
||||
required bytes data = 1;
|
||||
}
|
||||
|
||||
message BufferEvent {
|
||||
|
|
|
@ -2,7 +2,6 @@ syntax = "proto2";
|
|||
|
||||
package common;
|
||||
|
||||
|
||||
// a wrapper payload representing an uuid
|
||||
message Identity {
|
||||
// uuid bytes, as string
|
||||
|
|
|
@ -10,7 +10,6 @@ service Cursor {
|
|||
rpc Attach (stream cursor.CursorPosition) returns (stream cursor.CursorEvent);
|
||||
}
|
||||
|
||||
|
||||
// a tuple indicating row and column
|
||||
message RowCol {
|
||||
required int32 row = 1;
|
||||
|
|
|
@ -46,8 +46,8 @@ message WorkspaceEvent {
|
|||
}
|
||||
|
||||
// TODO this is very ugly because we can't just return a new token (which is already smelly but whatev), we also need to tell the underlying id so that
|
||||
// the client can put it as metadata while attaching, because it can't really know the underlying id that the server is using for each buffer without
|
||||
// parsing the token itself. meehhhhhh, this bleeds underlying implementation to the upper levels, how can we avoid this??
|
||||
// the client can put it as metadata while attaching, because it can't really know the underlying id that the server is using for each buffer without
|
||||
// parsing the token itself. meehhhhhh, this bleeds underlying implementation to the upper levels, how can we avoid this??
|
||||
message BufferCredentials {
|
||||
required common.Identity id = 1;
|
||||
required auth.Token token = 2;
|
||||
|
|
21
src/lib.rs
21
src/lib.rs
|
@ -28,7 +28,6 @@ pub mod proto {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
pub mod files {
|
||||
tonic::include_proto!("files");
|
||||
|
||||
|
@ -40,7 +39,9 @@ pub mod proto {
|
|||
|
||||
impl From<&str> for BufferNode {
|
||||
fn from(value: &str) -> Self {
|
||||
BufferNode { path: value.to_string() }
|
||||
BufferNode {
|
||||
path: value.to_string(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -51,8 +52,16 @@ pub mod proto {
|
|||
}
|
||||
}
|
||||
|
||||
pub mod buffer { tonic::include_proto!("buffer"); }
|
||||
pub mod cursor { tonic::include_proto!("cursor"); }
|
||||
pub mod workspace { tonic::include_proto!("workspace"); }
|
||||
pub mod auth { tonic::include_proto!("auth"); }
|
||||
pub mod buffer {
|
||||
tonic::include_proto!("buffer");
|
||||
}
|
||||
pub mod cursor {
|
||||
tonic::include_proto!("cursor");
|
||||
}
|
||||
pub mod workspace {
|
||||
tonic::include_proto!("workspace");
|
||||
}
|
||||
pub mod auth {
|
||||
tonic::include_proto!("auth");
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue