Rename zrpc to rpc

Nathan Sobo and Max Brunsfeld created

Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>

Change summary

Cargo.lock                     | 56 ++++++++++++++++++------------------
crates/buffer/Cargo.toml       |  2 
crates/buffer/src/lib.rs       |  2 
crates/clock/Cargo.toml        |  2 
crates/clock/src/lib.rs        |  8 ++--
crates/rpc/Cargo.toml          |  2 
crates/rpc/build.rs            |  0 
crates/rpc/proto/zed.proto     |  0 
crates/rpc/src/auth.rs         |  0 
crates/rpc/src/conn.rs         |  0 
crates/rpc/src/lib.rs          |  0 
crates/rpc/src/peer.rs         |  0 
crates/rpc/src/proto.rs        |  0 
crates/rpc_client/Cargo.toml   |  2 
crates/rpc_client/src/lib.rs   | 12 +++----
crates/rpc_client/src/test.rs  |  2 
crates/server/Cargo.toml       |  2 
crates/server/src/auth.rs      |  2 
crates/server/src/main.rs      |  2 
crates/server/src/rpc.rs       |  6 +-
crates/server/src/rpc/store.rs |  2 
crates/worktree/Cargo.toml     |  4 +-
crates/worktree/src/lib.rs     |  3 -
crates/zed/Cargo.toml          |  6 +-
crates/zed/src/channel.rs      | 10 +++---
crates/zed/src/user.rs         |  3 -
26 files changed, 62 insertions(+), 66 deletions(-)

Detailed changes

Cargo.lock 🔗

@@ -754,6 +754,7 @@ dependencies = [
  "log",
  "parking_lot",
  "rand 0.8.3",
+ "rpc",
  "seahash",
  "serde 1.0.125",
  "similar",
@@ -762,7 +763,6 @@ dependencies = [
  "tree-sitter",
  "tree-sitter-rust",
  "unindent",
- "zrpc",
 ]
 
 [[package]]
@@ -1025,8 +1025,8 @@ dependencies = [
 name = "clock"
 version = "0.1.0"
 dependencies = [
+ "rpc",
  "smallvec",
- "zrpc",
 ]
 
 [[package]]
@@ -4087,6 +4087,28 @@ dependencies = [
  "xmlparser",
 ]
 
+[[package]]
+name = "rpc"
+version = "0.1.0"
+dependencies = [
+ "anyhow",
+ "async-lock",
+ "async-tungstenite",
+ "base64 0.13.0",
+ "futures",
+ "log",
+ "parking_lot",
+ "postage",
+ "prost",
+ "prost-build",
+ "rand 0.8.3",
+ "rsa",
+ "serde 1.0.125",
+ "smol",
+ "tempdir",
+ "zstd",
+]
+
 [[package]]
 name = "rpc_client"
 version = "0.1.0"
@@ -4100,12 +4122,12 @@ dependencies = [
  "parking_lot",
  "postage",
  "rand 0.8.3",
+ "rpc",
  "smol",
  "surf",
  "thiserror",
  "tiny_http",
  "util",
- "zrpc",
 ]
 
 [[package]]
@@ -5949,6 +5971,7 @@ dependencies = [
  "parking_lot",
  "postage",
  "rand 0.8.3",
+ "rpc",
  "rpc_client",
  "serde 1.0.125",
  "serde_json 1.0.64",
@@ -5957,7 +5980,6 @@ dependencies = [
  "tempdir",
  "toml 0.5.8",
  "util",
- "zrpc",
 ]
 
 [[package]]
@@ -6025,6 +6047,7 @@ dependencies = [
  "parking_lot",
  "postage",
  "rand 0.8.3",
+ "rpc",
  "rpc_client",
  "rsa",
  "rust-embed",
@@ -6047,7 +6070,6 @@ dependencies = [
  "url",
  "util",
  "worktree",
- "zrpc",
 ]
 
 [[package]]
@@ -6076,6 +6098,7 @@ dependencies = [
  "parking_lot",
  "postage",
  "rand 0.8.3",
+ "rpc",
  "rust-embed",
  "scrypt",
  "serde 1.0.125",
@@ -6088,7 +6111,6 @@ dependencies = [
  "time 0.2.25",
  "toml 0.5.8",
  "zed",
- "zrpc",
 ]
 
 [[package]]
@@ -6112,28 +6134,6 @@ dependencies = [
  "synstructure",
 ]
 
-[[package]]
-name = "zrpc"
-version = "0.1.0"
-dependencies = [
- "anyhow",
- "async-lock",
- "async-tungstenite",
- "base64 0.13.0",
- "futures",
- "log",
- "parking_lot",
- "postage",
- "prost",
- "prost-build",
- "rand 0.8.3",
- "rsa",
- "serde 1.0.125",
- "smol",
- "tempdir",
- "zstd",
-]
-
 [[package]]
 name = "zstd"
 version = "0.9.0+zstd.1.5.0"

crates/buffer/Cargo.toml 🔗

@@ -21,7 +21,7 @@ similar = "1.3"
 smallvec = { version = "1.6", features = ["union"] }
 sum_tree = { path = "../sum_tree" }
 tree-sitter = "0.19.5"
-zrpc = { path = "../zrpc" }
+rpc = { path = "../rpc" }
 
 [dev-dependencies]
 rand = "0.8.3"

crates/buffer/src/lib.rs 🔗

@@ -43,7 +43,7 @@ use std::{
 use sum_tree::{self, Bias, FilterCursor, SumTree};
 pub use syntax_theme::SyntaxTheme;
 use tree_sitter::{InputEdit, Parser, QueryCursor};
-use zrpc::proto;
+use rpc::proto;
 
 pub trait File {
     fn worktree_id(&self) -> usize;

crates/clock/Cargo.toml 🔗

@@ -5,4 +5,4 @@ edition = "2018"
 
 [dependencies]
 smallvec = { version = "1.6", features = ["union"] }
-zrpc = { path = "../zrpc" }
+rpc = { path = "../rpc" }

crates/clock/src/lib.rs 🔗

@@ -61,8 +61,8 @@ impl<'a> AddAssign<&'a Local> for Local {
 #[derive(Clone, Default, Hash, Eq, PartialEq)]
 pub struct Global(SmallVec<[Local; 3]>);
 
-impl From<Vec<zrpc::proto::VectorClockEntry>> for Global {
-    fn from(message: Vec<zrpc::proto::VectorClockEntry>) -> Self {
+impl From<Vec<rpc::proto::VectorClockEntry>> for Global {
+    fn from(message: Vec<rpc::proto::VectorClockEntry>) -> Self {
         let mut version = Self::new();
         for entry in message {
             version.observe(Local {
@@ -74,11 +74,11 @@ impl From<Vec<zrpc::proto::VectorClockEntry>> for Global {
     }
 }
 
-impl<'a> From<&'a Global> for Vec<zrpc::proto::VectorClockEntry> {
+impl<'a> From<&'a Global> for Vec<rpc::proto::VectorClockEntry> {
     fn from(version: &'a Global) -> Self {
         version
             .iter()
-            .map(|entry| zrpc::proto::VectorClockEntry {
+            .map(|entry| rpc::proto::VectorClockEntry {
                 replica_id: entry.replica_id as u32,
                 timestamp: entry.value,
             })

crates/zrpc/Cargo.toml → crates/rpc/Cargo.toml 🔗

@@ -1,7 +1,7 @@
 [package]
 description = "Shared logic for communication between the Zed app and the zed.dev server"
 edition = "2018"
-name = "zrpc"
+name = "rpc"
 version = "0.1.0"
 
 [features]

crates/rpc_client/Cargo.toml 🔗

@@ -21,4 +21,4 @@ surf = "2.2"
 thiserror = "1.0.29"
 tiny_http = "0.8"
 util = { path = "../util" }
-zrpc = { path = "../zrpc" }
+rpc = { path = "../rpc" }

crates/rpc_client/src/lib.rs 🔗

@@ -12,6 +12,7 @@ use lazy_static::lazy_static;
 use parking_lot::RwLock;
 use postage::{prelude::Stream, watch};
 use rand::prelude::*;
+use rpc::proto::{AnyTypedEnvelope, EntityMessage, EnvelopedMessage, RequestMessage};
 use std::{
     any::TypeId,
     collections::HashMap,
@@ -24,11 +25,8 @@ use std::{
 use surf::Url;
 use thiserror::Error;
 use util::ResultExt;
-pub use zrpc::{proto, ConnectionId, PeerId, TypedEnvelope};
-use zrpc::{
-    proto::{AnyTypedEnvelope, EntityMessage, EnvelopedMessage, RequestMessage},
-    Connection, Peer, Receipt,
-};
+
+pub use rpc::*;
 
 lazy_static! {
     static ref ZED_SERVER_URL: String =
@@ -506,7 +504,7 @@ impl Client {
                 "Authorization",
                 format!("{} {}", credentials.user_id, credentials.access_token),
             )
-            .header("X-Zed-Protocol-Version", zrpc::PROTOCOL_VERSION);
+            .header("X-Zed-Protocol-Version", rpc::PROTOCOL_VERSION);
         cx.background().spawn(async move {
             if let Some(host) = ZED_SERVER_URL.strip_prefix("https://") {
                 let stream = smol::net::TcpStream::connect(host).await?;
@@ -536,7 +534,7 @@ impl Client {
             // zed server to encrypt the user's access token, so that it can'be intercepted by
             // any other app running on the user's device.
             let (public_key, private_key) =
-                zrpc::auth::keypair().expect("failed to generate keypair for auth");
+                rpc::auth::keypair().expect("failed to generate keypair for auth");
             let public_key_string =
                 String::try_from(public_key).expect("failed to serialize public key for auth");
 

crates/rpc_client/src/test.rs 🔗

@@ -5,11 +5,11 @@ use super::Client;
 use gpui::TestAppContext;
 use parking_lot::Mutex;
 use postage::{mpsc, prelude::Stream};
+use rpc::{proto, ConnectionId, Peer, Receipt, TypedEnvelope};
 use std::sync::{
     atomic::{AtomicBool, AtomicUsize},
     Arc,
 };
-use zrpc::{proto, ConnectionId, Peer, Receipt, TypedEnvelope};
 
 pub struct FakeServer {
     peer: Arc<Peer>,

crates/server/Cargo.toml 🔗

@@ -41,7 +41,7 @@ tide = "0.16.0"
 tide-compress = "0.9.0"
 time = "0.2"
 toml = "0.5.8"
-zrpc = { path = "../zrpc" }
+rpc = { path = "../rpc" }
 
 [dependencies.async-sqlx-session]
 version = "0.3.0"

crates/server/src/auth.rs 🔗

@@ -19,7 +19,7 @@ use serde::{Deserialize, Serialize};
 use std::{borrow::Cow, convert::TryFrom, sync::Arc};
 use surf::{StatusCode, Url};
 use tide::{log, Error, Server};
-use zrpc::auth as zed_auth;
+use rpc::auth as zed_auth;
 
 static CURRENT_GITHUB_USER: &'static str = "current_github_user";
 static GITHUB_AUTH_URL: &'static str = "https://github.com/login/oauth/authorize";

crates/server/src/main.rs 🔗

@@ -26,7 +26,7 @@ use std::sync::Arc;
 use surf::http::cookies::SameSite;
 use tide::{log, sessions::SessionMiddleware};
 use tide_compress::CompressMiddleware;
-use zrpc::Peer;
+use rpc::Peer;
 
 type Request = tide::Request<Arc<AppState>>;
 

crates/server/src/rpc.rs 🔗

@@ -27,7 +27,7 @@ use tide::{
     Request, Response,
 };
 use time::OffsetDateTime;
-use zrpc::{
+use rpc::{
     proto::{self, AnyTypedEnvelope, EnvelopedMessage},
     Connection, ConnectionId, Peer, TypedEnvelope,
 };
@@ -897,7 +897,7 @@ pub fn add_routes(app: &mut tide::Server<Arc<AppState>>, rpc: &Arc<Peer>) {
                 .header("X-Zed-Protocol-Version")
                 .and_then(|v| v.as_str().parse().ok());
 
-            if !upgrade_requested || client_protocol_version != Some(zrpc::PROTOCOL_VERSION) {
+            if !upgrade_requested || client_protocol_version != Some(rpc::PROTOCOL_VERSION) {
                 return Ok(Response::new(StatusCode::UpgradeRequired));
             }
 
@@ -988,7 +988,7 @@ mod tests {
         workspace::Workspace,
         worktree::Worktree,
     };
-    use zrpc::Peer;
+    use rpc::Peer;
 
     #[gpui::test]
     async fn test_share_worktree(mut cx_a: TestAppContext, mut cx_b: TestAppContext) {

crates/server/src/rpc/store.rs 🔗

@@ -1,7 +1,7 @@
 use crate::db::{ChannelId, UserId};
 use anyhow::anyhow;
 use std::collections::{hash_map, HashMap, HashSet};
-use zrpc::{proto, ConnectionId};
+use rpc::{proto, ConnectionId};
 
 #[derive(Default)]
 pub struct Store {

crates/worktree/Cargo.toml 🔗

@@ -28,11 +28,11 @@ smol = "1.2.5"
 sum_tree = { path = "../sum_tree" }
 util = { path = "../util" }
 toml = "0.5"
-zrpc = { path = "../zrpc" }
+rpc = { path = "../rpc" }
 
 [dev-dependencies]
 rand = "0.8.3"
 rpc_client = { path = "../rpc_client", features = ["test-support"] }
 tempdir = { version = "0.3.7" }
 util = { path = "../util", features = ["test-support"] }
-zrpc = { path = "../zrpc", features = ["test-support"] }
+rpc = { path = "../rpc", features = ["test-support"] }

crates/worktree/src/lib.rs 🔗

@@ -19,7 +19,7 @@ use postage::{
     prelude::{Sink as _, Stream as _},
     watch,
 };
-use rpc_client as rpc;
+use rpc_client::{self as rpc, proto, PeerId, TypedEnvelope};
 use serde::Deserialize;
 use smol::channel::{self, Sender};
 use std::{
@@ -41,7 +41,6 @@ use std::{
 use sum_tree::Bias;
 use sum_tree::{self, Edit, SeekTarget, SumTree};
 use util::TryFutureExt;
-use zrpc::{proto, PeerId, TypedEnvelope};
 
 lazy_static! {
     static ref GITIGNORE: &'static OsStr = OsStr::new(".gitignore");

crates/zed/Cargo.toml 🔗

@@ -20,7 +20,7 @@ test-support = [
     "rpc_client/test-support",
     "tempdir",
     "worktree/test-support",
-    "zrpc/test-support",
+    "rpc/test-support",
 ]
 
 [dependencies]
@@ -71,7 +71,7 @@ tree-sitter-rust = "0.19.0"
 url = "2.2"
 util = { path = "../util" }
 worktree =  { path = "../worktree" }
-zrpc = { path = "../zrpc" }
+rpc = { path = "../rpc" }
 
 [dev-dependencies]
 cargo-bundle = "0.5.0"
@@ -84,7 +84,7 @@ gpui = { path = "../gpui", features = ["test-support"] }
 rpc_client = { path = "../rpc_client", features = ["test-support"] }
 util = { path = "../util", features = ["test-support"] }
 worktree = { path = "../worktree", features = ["test-support"] }
-zrpc = { path = "../zrpc", features = ["test-support"] }
+rpc = { path = "../rpc", features = ["test-support"] }
 
 [package.metadata.bundle]
 icon = ["app-icon@2x.png", "app-icon.png"]

crates/zed/src/channel.rs 🔗

@@ -5,7 +5,11 @@ use gpui::{
 };
 use postage::prelude::Stream;
 use rand::prelude::*;
-use rpc_client as rpc;
+use rpc_client::{
+    self as rpc,
+    proto::{self, ChannelMessageSent},
+    TypedEnvelope,
+};
 use std::{
     collections::{HashMap, HashSet},
     mem,
@@ -15,10 +19,6 @@ use std::{
 use sum_tree::{self, Bias, SumTree};
 use time::OffsetDateTime;
 use util::{post_inc, TryFutureExt};
-use zrpc::{
-    proto::{self, ChannelMessageSent},
-    TypedEnvelope,
-};
 
 pub struct ChannelList {
     available_channels: Option<Vec<ChannelDetails>>,

crates/zed/src/user.rs 🔗

@@ -3,13 +3,12 @@ use anyhow::{anyhow, Context, Result};
 use futures::future;
 use gpui::{AsyncAppContext, Entity, ImageData, ModelContext, ModelHandle, Task};
 use postage::{prelude::Stream, sink::Sink, watch};
-use rpc_client as rpc;
+use rpc_client::{self as rpc, proto, TypedEnvelope};
 use std::{
     collections::{HashMap, HashSet},
     sync::Arc,
 };
 use util::TryFutureExt as _;
-use zrpc::{proto, TypedEnvelope};
 
 #[derive(Debug)]
 pub struct User {