diff --git a/Cargo.lock b/Cargo.lock index bdd8bf26c4..27e45aa38c 100644 --- a/Cargo.lock +++ b/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" diff --git a/crates/buffer/Cargo.toml b/crates/buffer/Cargo.toml index 48bfa8d14b..a5fb5e9c54 100644 --- a/crates/buffer/Cargo.toml +++ b/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" diff --git a/crates/buffer/src/lib.rs b/crates/buffer/src/lib.rs index 07865af34c..a857f47976 100644 --- a/crates/buffer/src/lib.rs +++ b/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; diff --git a/crates/clock/Cargo.toml b/crates/clock/Cargo.toml index 9770b1d7d7..3e5d84935d 100644 --- a/crates/clock/Cargo.toml +++ b/crates/clock/Cargo.toml @@ -5,4 +5,4 @@ edition = "2018" [dependencies] smallvec = { version = "1.6", features = ["union"] } -zrpc = { path = "../zrpc" } +rpc = { path = "../rpc" } diff --git a/crates/clock/src/lib.rs b/crates/clock/src/lib.rs index 96418131f2..ee5c0dba03 100644 --- a/crates/clock/src/lib.rs +++ b/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> for Global { - fn from(message: Vec) -> Self { +impl From> for Global { + fn from(message: Vec) -> Self { let mut version = Self::new(); for entry in message { version.observe(Local { @@ -74,11 +74,11 @@ impl From> for Global { } } -impl<'a> From<&'a Global> for Vec { +impl<'a> From<&'a Global> for Vec { 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, }) diff --git a/crates/zrpc/Cargo.toml b/crates/rpc/Cargo.toml similarity index 97% rename from crates/zrpc/Cargo.toml rename to crates/rpc/Cargo.toml index 96f3604e76..8f43a28a3b 100644 --- a/crates/zrpc/Cargo.toml +++ b/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] diff --git a/crates/zrpc/build.rs b/crates/rpc/build.rs similarity index 100% rename from crates/zrpc/build.rs rename to crates/rpc/build.rs diff --git a/crates/zrpc/proto/zed.proto b/crates/rpc/proto/zed.proto similarity index 100% rename from crates/zrpc/proto/zed.proto rename to crates/rpc/proto/zed.proto diff --git a/crates/zrpc/src/auth.rs b/crates/rpc/src/auth.rs similarity index 100% rename from crates/zrpc/src/auth.rs rename to crates/rpc/src/auth.rs diff --git a/crates/zrpc/src/conn.rs b/crates/rpc/src/conn.rs similarity index 100% rename from crates/zrpc/src/conn.rs rename to crates/rpc/src/conn.rs diff --git a/crates/zrpc/src/lib.rs b/crates/rpc/src/lib.rs similarity index 100% rename from crates/zrpc/src/lib.rs rename to crates/rpc/src/lib.rs diff --git a/crates/zrpc/src/peer.rs b/crates/rpc/src/peer.rs similarity index 100% rename from crates/zrpc/src/peer.rs rename to crates/rpc/src/peer.rs diff --git a/crates/zrpc/src/proto.rs b/crates/rpc/src/proto.rs similarity index 100% rename from crates/zrpc/src/proto.rs rename to crates/rpc/src/proto.rs diff --git a/crates/rpc_client/Cargo.toml b/crates/rpc_client/Cargo.toml index 89695fda4c..384a8e56ea 100644 --- a/crates/rpc_client/Cargo.toml +++ b/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" } diff --git a/crates/rpc_client/src/lib.rs b/crates/rpc_client/src/lib.rs index 097fe1e66d..b62697b195 100644 --- a/crates/rpc_client/src/lib.rs +++ b/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"); diff --git a/crates/rpc_client/src/test.rs b/crates/rpc_client/src/test.rs index 055c5c1f8a..ec4a30465c 100644 --- a/crates/rpc_client/src/test.rs +++ b/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, diff --git a/crates/server/Cargo.toml b/crates/server/Cargo.toml index b295ff21ac..d5be7c8661 100644 --- a/crates/server/Cargo.toml +++ b/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" diff --git a/crates/server/src/auth.rs b/crates/server/src/auth.rs index 4a06c642eb..2e2f40fca7 100644 --- a/crates/server/src/auth.rs +++ b/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"; diff --git a/crates/server/src/main.rs b/crates/server/src/main.rs index 49b9a76cf9..b6b3ffc236 100644 --- a/crates/server/src/main.rs +++ b/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>; diff --git a/crates/server/src/rpc.rs b/crates/server/src/rpc.rs index dbb8b02f63..3012d17db6 100644 --- a/crates/server/src/rpc.rs +++ b/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>, rpc: &Arc) { .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) { diff --git a/crates/server/src/rpc/store.rs b/crates/server/src/rpc/store.rs index b33cd13558..ac9c069146 100644 --- a/crates/server/src/rpc/store.rs +++ b/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 { diff --git a/crates/worktree/Cargo.toml b/crates/worktree/Cargo.toml index 592f2908e9..4d9d4be4a1 100644 --- a/crates/worktree/Cargo.toml +++ b/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"] } diff --git a/crates/worktree/src/lib.rs b/crates/worktree/src/lib.rs index d284ba376b..3803401ed7 100644 --- a/crates/worktree/src/lib.rs +++ b/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"); diff --git a/crates/zed/Cargo.toml b/crates/zed/Cargo.toml index 0eb5e764d8..def8af297f 100644 --- a/crates/zed/Cargo.toml +++ b/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"] diff --git a/crates/zed/src/channel.rs b/crates/zed/src/channel.rs index 3da50032e9..48ecbb9fa2 100644 --- a/crates/zed/src/channel.rs +++ b/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>, diff --git a/crates/zed/src/user.rs b/crates/zed/src/user.rs index 63718345b7..106cbd7ba0 100644 --- a/crates/zed/src/user.rs +++ b/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 {