From 9c5c9fdc36aa0108f2f36d37dd1c7cb9e2d3bbab Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Wed, 9 Jun 2021 18:14:30 -0700 Subject: [PATCH] Add initial messages for setting up a worktree share --- zed-rpc/proto/zed.proto | 36 +++++++++++++++++++++++++++++++++--- zed-rpc/src/proto.rs | 15 +++++++++++++-- 2 files changed, 46 insertions(+), 5 deletions(-) diff --git a/zed-rpc/proto/zed.proto b/zed-rpc/proto/zed.proto index 94a4d173b157a4a4d63e12ceb2cf1bf408f06472..4419c3bc827ac104b9da7f2e343c64c1d64be9c6 100644 --- a/zed-rpc/proto/zed.proto +++ b/zed-rpc/proto/zed.proto @@ -6,22 +6,52 @@ message FromClient { oneof variant { Auth auth = 2; + NewWorktree new_worktree = 3; + ShareWorktree share_worktree = 4; + UploadFile upload_file = 5; } message Auth { int32 user_id = 1; string access_token = 2; } + + message NewWorktree {} + + message ShareWorktree { + uint64 worktree_id = 1; + repeated PathAndDigest files = 2; + } + + message PathAndDigest { + bytes path = 1; + bytes digest = 2; + } + + message UploadFile { + bytes path = 1; + bytes content = 2; + } } message FromServer { optional int32 request_id = 1; oneof variant { - Ack ack = 2; + AuthResponse auth_response = 2; + NewWorktreeResponse new_worktree_response = 3; + ShareWorktreeResponse share_worktree_response = 4; + } + + message AuthResponse { + bool credentials_valid = 1; + } + + message NewWorktreeResponse { + uint64 worktree_id = 1; } - message Ack { - optional string error_message = 1; + message ShareWorktreeResponse { + repeated int32 needed_file_indices = 1; } } \ No newline at end of file diff --git a/zed-rpc/src/proto.rs b/zed-rpc/src/proto.rs index 177dbd6fa2312adf05ba3c35bb5416fc559e668c..6cac6283375149a2f1a80c8eccce88429aae7eb5 100644 --- a/zed-rpc/src/proto.rs +++ b/zed-rpc/src/proto.rs @@ -5,14 +5,25 @@ use std::io; include!(concat!(env!("OUT_DIR"), "/zed.messages.rs")); +use from_client as client; +use from_server as server; + pub trait Request { type Response; } -impl Request for from_client::Auth { - type Response = from_server::Ack; +macro_rules! request_response { + ($req:path, $resp:path) => { + impl Request for $req { + type Response = $resp; + } + }; } +request_response!(client::Auth, server::AuthResponse); +request_response!(client::NewWorktree, server::NewWorktreeResponse); +request_response!(client::ShareWorktree, server::ShareWorktreeResponse); + /// A stream of protobuf messages. pub struct MessageStream { byte_stream: T,