diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..4f4d8ca --- /dev/null +++ b/.editorconfig @@ -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 diff --git a/.rustfmt.toml b/.rustfmt.toml new file mode 100644 index 0000000..218e203 --- /dev/null +++ b/.rustfmt.toml @@ -0,0 +1 @@ +hard_tabs = true diff --git a/build.rs b/build.rs index 31679d6..98c52ca 100644 --- a/build.rs +++ b/build.rs @@ -1,15 +1,13 @@ fn main() -> Result<(), Box> { - 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"], + )?) +} diff --git a/proto/auth.proto b/proto/auth.proto index 39f7a20..0f8c53a 100644 --- a/proto/auth.proto +++ b/proto/auth.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; } diff --git a/proto/buffer.proto b/proto/buffer.proto index e018440..826bc9b 100644 --- a/proto/buffer.proto +++ b/proto/buffer.proto @@ -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 { diff --git a/proto/common.proto b/proto/common.proto index 6b7ce31..adae915 100644 --- a/proto/common.proto +++ b/proto/common.proto @@ -2,7 +2,6 @@ syntax = "proto2"; package common; - // a wrapper payload representing an uuid message Identity { // uuid bytes, as string diff --git a/proto/cursor.proto b/proto/cursor.proto index 0b4861b..93a1592 100644 --- a/proto/cursor.proto +++ b/proto/cursor.proto @@ -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; diff --git a/proto/workspace.proto b/proto/workspace.proto index 26eaa04..bd7aaf2 100644 --- a/proto/workspace.proto +++ b/proto/workspace.proto @@ -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; diff --git a/src/lib.rs b/src/lib.rs index bd4e025..9569730 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -14,7 +14,7 @@ pub mod proto { Identity { id: id.to_string() } } } - + impl From for uuid::Uuid { fn from(value: Identity) -> Self { uuid::Uuid::parse_str(&value.id).expect("invalid uuid in identity") @@ -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"); } -} \ No newline at end of file + 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"); + } +}