Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Move ProtoClient to RPC crate, behind feature flag disabled in collab (#17908)
Max Brunsfeld01bb10f5186d
diff --git a/Cargo.lock b/Cargo.lockindex a6d351099b9..d0af85057d2 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -418,6 +418,7 @@ dependencies = ["regex","release_channel","rope",+ "rpc","schemars","search","semantic_index",@@ -8553,9 +8554,6 @@ version = "0.1.0"dependencies = ["anyhow","collections",- "futures 0.3.30",- "gpui",- "parking_lot","prost","prost-build","serde",diff --git a/crates/assistant/Cargo.toml b/crates/assistant/Cargo.tomlindex d2b5aed9bd8..b700702062c 100644--- a/crates/assistant/Cargo.toml+++ b/crates/assistant/Cargo.toml@@ -65,6 +65,7 @@ proto.workspace = trueregex.workspace = truerelease_channel.workspace = truerope.workspace = true+rpc.workspace = trueschemars.workspace = truesearch.workspace = truesemantic_index.workspace = truediff --git a/crates/assistant/src/context_store.rs b/crates/assistant/src/context_store.rsindex b6e1650c41d..867d9067914 100644--- a/crates/assistant/src/context_store.rs+++ b/crates/assistant/src/context_store.rs@@ -2,7 +2,6 @@ use crate::{prompts::PromptBuilder, Context, ContextEvent, ContextId, ContextOperation, ContextVersion,SavedContext, SavedContextMetadata,};-use ::proto::AnyProtoClient;use anyhow::{anyhow, Context as _, Result};use client::{proto, telemetry::Telemetry, Client, TypedEnvelope};use clock::ReplicaId;@@ -16,6 +15,7 @@ use language::LanguageRegistry;use paths::contexts_dir;use project::Project;use regex::Regex;+use rpc::AnyProtoClient;use std::{cmp::Reverse,ffi::OsStr,diff --git a/crates/channel/src/channel_buffer.rs b/crates/channel/src/channel_buffer.rsindex bf32185b220..2041b16a6da 100644--- a/crates/channel/src/channel_buffer.rs+++ b/crates/channel/src/channel_buffer.rs@@ -5,8 +5,8 @@ use collections::HashMap;use gpui::{AppContext, AsyncAppContext, Context, EventEmitter, Model, ModelContext, Task};use language::proto::serialize_version;use rpc::{- proto::{self, AnyProtoClient, PeerId},- TypedEnvelope,+ proto::{self, PeerId},+ AnyProtoClient, TypedEnvelope,};use std::{sync::Arc, time::Duration};use text::BufferId;diff --git a/crates/channel/src/channel_chat.rs b/crates/channel/src/channel_chat.rsindex 7cbc362ff35..286eb46a916 100644--- a/crates/channel/src/channel_chat.rs+++ b/crates/channel/src/channel_chat.rs@@ -11,7 +11,7 @@ use gpui::{AppContext, AsyncAppContext, Context, EventEmitter, Model, ModelContext, Task, WeakModel,};use rand::prelude::*;-use rpc::proto::AnyProtoClient;+use rpc::AnyProtoClient;use std::{ops::{ControlFlow, Range},sync::Arc,diff --git a/crates/client/Cargo.toml b/crates/client/Cargo.tomlindex 72ca8ffc247..82237ebaa5a 100644--- a/crates/client/Cargo.toml+++ b/crates/client/Cargo.toml@@ -34,7 +34,7 @@ parking_lot.workspace = truepostage.workspace = truerand.workspace = truerelease_channel.workspace = true-rpc.workspace = true+rpc = { workspace = true, features = ["gpui"] }schemars.workspace = trueserde.workspace = trueserde_json.workspace = truediff --git a/crates/client/src/client.rs b/crates/client/src/client.rsindex 8787e2ed967..6e1362c43e1 100644--- a/crates/client/src/client.rs+++ b/crates/client/src/client.rs@@ -22,7 +22,6 @@ use gpui::{actions, AppContext, AsyncAppContext, Global, Model, Task, WeakModel}use http_client::{AsyncBody, HttpClient, HttpClientWithUrl};use parking_lot::RwLock;use postage::watch;-use proto::{AnyProtoClient, EntityMessageSubscriber, ProtoClient, ProtoMessageHandlerSet};use rand::prelude::*;use release_channel::{AppVersion, ReleaseChannel};use rpc::proto::{AnyTypedEnvelope, EnvelopedMessage, PeerId, RequestMessage};diff --git a/crates/project/src/buffer_store.rs b/crates/project/src/buffer_store.rsindex 9bbc2f43589..403b53745a5 100644--- a/crates/project/src/buffer_store.rs+++ b/crates/project/src/buffer_store.rs@@ -17,10 +17,7 @@ use language::{proto::{deserialize_line_ending, deserialize_version, serialize_version, split_operations},Buffer, Capability, Event as BufferEvent, File as _, Language, Operation,};-use rpc::{- proto::{self, AnyProtoClient},- ErrorExt as _, TypedEnvelope,-};+use rpc::{proto, AnyProtoClient, ErrorExt as _, TypedEnvelope};use smol::channel::Receiver;use std::{io, path::Path, str::FromStr as _, sync::Arc, time::Instant};use text::BufferId;diff --git a/crates/project/src/lsp_store.rs b/crates/project/src/lsp_store.rsindex 668bdae4dc7..854915e82d6 100644--- a/crates/project/src/lsp_store.rs+++ b/crates/project/src/lsp_store.rs@@ -49,7 +49,7 @@ use parking_lot::{Mutex, RwLock};use postage::watch;use rand::prelude::*;-use rpc::proto::AnyProtoClient;+use rpc::AnyProtoClient;use serde::Serialize;use settings::{Settings, SettingsLocation, SettingsStore};use sha2::{Digest, Sha256};diff --git a/crates/project/src/project.rs b/crates/project/src/project.rsindex f67423b0738..8fca2ea6863 100644--- a/crates/project/src/project.rs+++ b/crates/project/src/project.rs@@ -62,10 +62,7 @@ use paths::{local_tasks_file_relative_path, local_vscode_tasks_file_relative_patuse prettier_support::{DefaultPrettier, PrettierInstance};use project_settings::{LspSettings, ProjectSettings, SettingsObserver};use remote::SshSession;-use rpc::{- proto::{AnyProtoClient, SSH_PROJECT_ID},- ErrorCode,-};+use rpc::{proto::SSH_PROJECT_ID, AnyProtoClient, ErrorCode};use search::{SearchInputKind, SearchQuery, SearchResult};use search_history::SearchHistory;use settings::{watch_config_file, Settings, SettingsLocation, SettingsStore};diff --git a/crates/project/src/project_settings.rs b/crates/project/src/project_settings.rsindex 70b2eccf237..2eeb8408961 100644--- a/crates/project/src/project_settings.rs+++ b/crates/project/src/project_settings.rs@@ -2,10 +2,7 @@ use collections::HashMap;use fs::Fs;use gpui::{AppContext, AsyncAppContext, BorrowAppContext, Model, ModelContext};use paths::local_settings_file_relative_path;-use rpc::{- proto::{self, AnyProtoClient},- TypedEnvelope,-};+use rpc::{proto, AnyProtoClient, TypedEnvelope};use schemars::JsonSchema;use serde::{Deserialize, Serialize};use settings::{Settings, SettingsSources, SettingsStore};diff --git a/crates/project/src/worktree_store.rs b/crates/project/src/worktree_store.rsindex 6e03e614da8..8b620de43e0 100644--- a/crates/project/src/worktree_store.rs+++ b/crates/project/src/worktree_store.rs@@ -17,8 +17,8 @@ use gpui::{};use postage::oneshot;use rpc::{- proto::{self, AnyProtoClient, SSH_PROJECT_ID},- TypedEnvelope,+ proto::{self, SSH_PROJECT_ID},+ AnyProtoClient, TypedEnvelope,};use smol::{channel::{Receiver, Sender},diff --git a/crates/proto/Cargo.toml b/crates/proto/Cargo.tomlindex e1d111366c9..eca020a92dd 100644--- a/crates/proto/Cargo.toml+++ b/crates/proto/Cargo.toml@@ -19,11 +19,8 @@ doctest = false[dependencies]anyhow.workspace = truecollections.workspace = true-futures.workspace = true-parking_lot.workspace = trueprost.workspace = trueserde.workspace = true-gpui.workspace = true[build-dependencies]prost-build.workspace = truediff --git a/crates/proto/src/proto.rs b/crates/proto/src/proto.rsindex 7af66a6a6be..a1853ed4a3b 100644--- a/crates/proto/src/proto.rs+++ b/crates/proto/src/proto.rs@@ -2,11 +2,9 @@pub mod error;mod macros;-mod proto_client;mod typed_envelope;pub use error::*;-pub use proto_client::*;pub use typed_envelope::*;use collections::HashMap;diff --git a/crates/remote/Cargo.toml b/crates/remote/Cargo.tomlindex 2e96d8062e6..5c291b59d34 100644--- a/crates/remote/Cargo.toml+++ b/crates/remote/Cargo.toml@@ -26,7 +26,7 @@ gpui.workspace = truelog.workspace = trueparking_lot.workspace = trueprost.workspace = true-rpc.workspace = true+rpc = { workspace = true, features = ["gpui"] }serde.workspace = trueserde_json.workspace = truesmol.workspace = truediff --git a/crates/remote/src/ssh_session.rs b/crates/remote/src/ssh_session.rsindex 5ff11fe0993..4762a785dbd 100644--- a/crates/remote/src/ssh_session.rs+++ b/crates/remote/src/ssh_session.rs@@ -13,9 +13,9 @@ use futures::{};use gpui::{AppContext, AsyncAppContext, Model, SemanticVersion};use parking_lot::Mutex;-use rpc::proto::{- self, build_typed_envelope, EntityMessageSubscriber, Envelope, EnvelopedMessage, PeerId,- ProtoClient, ProtoMessageHandlerSet, RequestMessage,+use rpc::{+ proto::{self, build_typed_envelope, Envelope, EnvelopedMessage, PeerId, RequestMessage},+ EntityMessageSubscriber, ProtoClient, ProtoMessageHandlerSet,};use smol::{fs,diff --git a/crates/remote_server/src/headless_project.rs b/crates/remote_server/src/headless_project.rsindex c8ec49cc1e2..08723daa01d 100644--- a/crates/remote_server/src/headless_project.rs+++ b/crates/remote_server/src/headless_project.rs@@ -8,8 +8,8 @@ use project::{};use remote::SshSession;use rpc::{- proto::{self, AnyProtoClient, SSH_PEER_ID, SSH_PROJECT_ID},- TypedEnvelope,+ proto::{self, SSH_PEER_ID, SSH_PROJECT_ID},+ AnyProtoClient, TypedEnvelope,};use smol::stream::StreamExt;use std::{diff --git a/crates/rpc/Cargo.toml b/crates/rpc/Cargo.tomlindex 79cb811afa5..f664085f04c 100644--- a/crates/rpc/Cargo.toml+++ b/crates/rpc/Cargo.toml@@ -14,6 +14,7 @@ path = "src/rpc.rs"doctest = false[features]+gpui = ["dep:gpui"]test-support = ["collections/test-support", "gpui/test-support", "proto/test-support"][dependencies]@@ -39,7 +40,6 @@ zstd = "0.11"[target.'cfg(target_os = "linux")'.dependencies]zstd = { version = "0.11", features = [ "pkg-config" ] }-[dev-dependencies]collections = { workspace = true, features = ["test-support"] }env_logger.workspace = truediff --git a/crates/proto/src/proto_client.rs b/crates/rpc/src/proto_client.rssimilarity index 99%rename from crates/proto/src/proto_client.rsrename to crates/rpc/src/proto_client.rsindex edcb6417d8f..4a990a84336 100644--- a/crates/proto/src/proto_client.rs+++ b/crates/rpc/src/proto_client.rs@@ -1,7 +1,3 @@-use crate::{- error::ErrorExt as _, AnyTypedEnvelope, EntityMessage, Envelope, EnvelopedMessage,- RequestMessage, TypedEnvelope,-};use anyhow::anyhow;use collections::HashMap;use futures::{@@ -9,7 +5,11 @@ use futures::{Future, FutureExt as _,};use gpui::{AnyModel, AnyWeakModel, AsyncAppContext, Model};-pub use prost::Message;+// pub use prost::Message;+use proto::{+ error::ErrorExt as _, AnyTypedEnvelope, EntityMessage, Envelope, EnvelopedMessage,+ RequestMessage, TypedEnvelope,+};use std::{any::TypeId, sync::Arc};#[derive(Clone)]diff --git a/crates/rpc/src/rpc.rs b/crates/rpc/src/rpc.rsindex 2e8b1ef6b7a..9c622387332 100644--- a/crates/rpc/src/rpc.rs+++ b/crates/rpc/src/rpc.rs@@ -14,4 +14,9 @@ pub use peer::*;pub use proto::{error::*, Receipt, TypedEnvelope};mod macros;+#[cfg(feature = "gpui")]+mod proto_client;+#[cfg(feature = "gpui")]+pub use proto_client::*;+pub const PROTOCOL_VERSION: u32 = 68;diff --git a/crates/worktree/src/worktree.rs b/crates/worktree/src/worktree.rsindex 584524a1d7b..776c01c49c2 100644--- a/crates/worktree/src/worktree.rs+++ b/crates/worktree/src/worktree.rs@@ -36,7 +36,7 @@ use postage::{prelude::{Sink as _, Stream as _},watch,};-use rpc::proto::{self, AnyProtoClient};+use rpc::{proto, AnyProtoClient};pub use settings::WorktreeId;use settings::{Settings, SettingsLocation, SettingsStore};use smallvec::{smallvec, SmallVec};