Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ name: build+test

on:
push:
branches:
- dev

env:
CARGO_TERM_COLOR: always
Expand Down
3 changes: 2 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ authors = [
"cschen <cschen@codemp.dev>"
]
license = "GPL-3.0-only"
version = "0.7.2"
version = "0.8.0"
edition = "2024"

[lib]
Expand Down
4 changes: 3 additions & 1 deletion proto/buffer.proto
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ package buffer;
service Buffer {
// Attach to a buffer and receive operations.
rpc Attach (stream Operation) returns (stream BufferEvent);
// Kicks all active users from the buffer.
rpc KickAll (common.Empty) returns (common.Empty);
}

// Message representing an operation that has occurred.
Expand All @@ -21,5 +23,5 @@ message BufferEvent {
// The operation that occurred.
required Operation op = 1;
// The user that sent this event.
required common.Identity user = 2;
required common.Identifier user = 2;
}
14 changes: 12 additions & 2 deletions proto/common.proto
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ message Token {
}

// Message representing a UUID.
message Identity {
message Identifier {
// The most significant bits of the UUID.
required uint64 hi = 1;
// The least significant bits of the UUID.
Expand All @@ -18,10 +18,20 @@ message Identity {
// Message representing a user.
message User {
// The UUID of the user.
required Identity id = 1;
required Identifier id = 1;
// The name of a user.
required string name = 2;
}

// Message representing a workspace.
message WorkspaceInfo {
// The UUID of the workspace.
required Identifier id = 1;
// The owner of the workspace, for easy namespacing.
required User owner = 2;
// Mnemonical name of the workspace.
required string name = 3;
}

// A generic empty message.
message Empty { }
12 changes: 10 additions & 2 deletions proto/cursor.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,18 @@ import "files.proto";

// Handles cursor events and broadcasts them to all users.
service Cursor {
// Retrieves all current cursor positions.
rpc List(common.Empty) returns (CursorEventList);
// Subscribe to a workspace's cursor events.
rpc Attach (stream cursor.CursorPosition) returns (stream cursor.CursorEvent);
}

// A message representing a list of cursor events.
message CursorEventList {
// A vector of cursor events.
repeated CursorEvent cursors = 1;
}

// A message representing a position in a buffer.
message RowCol {
// The row.
Expand All @@ -31,7 +39,7 @@ message CursorPosition {
// A message representing a cursor event.
message CursorEvent {
// The user moving the cursor.
required common.Identity user = 1;
required common.Identifier user = 1;
// The new cursor position.
required CursorPosition position = 2;
repeated CursorPosition position = 2;
}
8 changes: 8 additions & 0 deletions proto/files.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,18 @@ syntax = "proto2";

package files;

// A message representing a buffer request.
message BufferRequest {
// The path of a buffer.
required string path = 1;
}

// A message representing a node in the filetree.
message BufferNode {
// The path of a buffer.
required string path = 1;
// Whether the buffer is ephemeral;
required bool ephemeral = 2;
}

// A message representing a filetree.
Expand Down
77 changes: 64 additions & 13 deletions proto/session.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,87 @@ import "common.proto";

// Manages user workspaces and refreshes tokens.
service Session {
// Attach to a session and receive events.
rpc Attach (common.Empty) returns (stream SessionEvent);
// Handle a workspace access request and return a workspace token.
rpc AccessWorkspace (WorkspaceRequest) returns (common.Token);
// Create a workspace.
rpc CreateWorkspace (WorkspaceRequest) returns (common.Empty);
rpc CreateWorkspace (OwnedWorkspaceRequest) returns (common.WorkspaceInfo);
// Delete a workspace.
rpc DeleteWorkspace (WorkspaceRequest) returns (common.Empty);
// List all available workspaces.
rpc ListWorkspaces (common.Empty) returns (WorkspaceList);
rpc DeleteWorkspace (OwnedWorkspaceRequest) returns (common.Empty);
// List all workspaces the user has been invited to.
rpc FetchInvitedWorkspaces (common.Empty) returns (WorkspacesInvitedList);
//List all workspaces the user owns.
rpc FetchOwnedWorkspaces (common.Empty) returns (WorkspacesOwnedList);
// Handle a workspace invite request.
rpc InviteToWorkspace (InviteRequest) returns (common.Empty);
}

// A message representing a request for specific workspace.
// A message representing a request for an owned workspace.
message OwnedWorkspaceRequest {
// The workspace's name.
required string name = 1;
}

// A message representing a request for a specific workspace.
message WorkspaceRequest {
// The name of the workspace.
required string workspace = 1;
required common.Identifier id = 1;
}

// A message representing a list of workspaces.
message WorkspaceList {
// A vector of workspaces owned by the user.
repeated string owned = 1;
message WorkspacesInvitedList {
// A vector of workspaces the user is invited to.
repeated string invited = 2;
repeated common.WorkspaceInfo invited = 1;
}

// A message representing a list of workspaces.
message WorkspacesOwnedList {
// A vector of workspaces owned by the user.
repeated common.WorkspaceInfo owned = 1;
}

// A message representing an invitation to a workspace.
message InviteRequest {
// The user the invitation is for.
required string user = 1;
// the workspace the invitation is for
required string workspace = 2;
// The workspace the invitation is for.
required common.Identifier workspace = 2;
}

// A message representing a session event.
message SessionEvent {
// Event that occurs when you get invited to a workspace.
message InvitationEvent {
// The user that invited you.
required common.User user = 1;
// The workspace the invitation is for.
required common.WorkspaceInfo workspace = 2;
}
// Event that occurs when a user quits a workspace.
message QuitEvent {
// The user that quits.
required common.User user = 1;
// The workspace the user quit.
required common.WorkspaceInfo workspace = 2;
}
// Event that occurs when an user accepts an invite to a workspace you are in.
message AcceptEvent {
// The user that accepted the invite.
required common.User user = 1;
// The workspace the user accepted the invite for.
required common.WorkspaceInfo workspace = 2;
}
// Event that occurs when an user rejects an invite.
message RejectEvent {
// The user that rejected the invite.
required common.User user = 1;
// The workspace the invitation was for.
required common.WorkspaceInfo workspace = 2;
}
oneof event {
InvitationEvent invite = 1;
QuitEvent leave = 2;
AcceptEvent join = 3;
RejectEvent reject = 4;
}
}
14 changes: 10 additions & 4 deletions proto/workspace.proto
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,18 @@ service Workspace {
rpc CreateBuffer (files.BufferNode) returns (common.Empty);
// Access a buffer within the workspace and returns a buffer token for it.
rpc AccessBuffer (files.BufferNode) returns (common.Token);
// Transforms an ephemeral buffer in a persistent one.
rpc PinBuffer (files.BufferRequest) returns (common.Empty);
// Delete a buffer.
rpc DeleteBuffer (files.BufferNode) returns (common.Empty);
// List buffers in the workspace.
rpc ListBuffers (common.Empty) returns (files.BufferTree);
rpc DeleteBuffer (files.BufferRequest) returns (common.Empty);
// List buffers in the workspace that are children of the given path.
rpc ListBuffers (files.BufferRequest) returns (files.BufferTree);
// List users in the workspace.
rpc ListUsers (common.Empty) returns (UserList);
// List users within a given buffer.
rpc ListBufferUsers (files.BufferNode) returns (UserList);
rpc ListBufferUsers (files.BufferRequest) returns (UserList);
// Revokes all invites and kicks all active users.
rpc KickAll (common.Empty) returns (common.Empty);
}

// A message representing a list of users.
Expand All @@ -45,6 +49,8 @@ message WorkspaceEvent {
message FileCreate {
// The path of the created file.
required string path = 1;
// Whether the buffer is ephemeral.
required bool ephemeral = 2;
}
// Event that occurs when a file is renamed in a workspace.
message FileRename {
Expand Down
38 changes: 9 additions & 29 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,33 @@
pub mod common {
tonic::include_proto!("common");

impl From<uuid::Uuid> for Identity {
impl From<uuid::Uuid> for Identifier {
fn from(id: uuid::Uuid) -> Self {
let (hi, lo) = id.as_u64_pair();
Identity { hi, lo }
Identifier { hi, lo }
}
}

impl From<&uuid::Uuid> for Identity {
impl From<&uuid::Uuid> for Identifier {
fn from(id: &uuid::Uuid) -> Self {
let (hi, lo) = id.as_u64_pair();
Identity { hi, lo }
Identifier { hi, lo }
}
}

impl From<Identity> for uuid::Uuid {
fn from(value: Identity) -> Self {
impl From<Identifier> for uuid::Uuid {
fn from(value: Identifier) -> Self {
uuid::Uuid::from_u64_pair(value.hi, value.lo)
}
}

impl From<&Identity> for uuid::Uuid {
fn from(value: &Identity) -> Self {
impl From<&Identifier> for uuid::Uuid {
fn from(value: &Identifier) -> Self {
uuid::Uuid::from_u64_pair(value.hi, value.lo)
}
}

impl Identity {
impl Identifier {
pub fn uuid(&self) -> uuid::Uuid {
uuid::Uuid::from(self)
}
Expand All @@ -46,26 +46,6 @@ pub mod common {
/// filetree related types
pub mod files {
tonic::include_proto!("files");

impl From<String> for BufferNode {
fn from(value: String) -> Self {
BufferNode { path: value }
}
}

impl From<&str> for BufferNode {
fn from(value: &str) -> Self {
BufferNode {
path: value.to_string(),
}
}
}

impl From<BufferNode> for String {
fn from(value: BufferNode) -> Self {
value.path
}
}
}

/// buffer synchronisation protocol types and procedures
Expand Down