Rename `room` crate to `call`

Antonio Scandurra and Nathan Sobo created

Also, rename `client::Call` to `client::IncomingCall`.

Co-Authored-By: Nathan Sobo <nathan@zed.dev>

Change summary

Cargo.lock                                         | 30 ++++++++--------
crates/call/Cargo.toml                             |  4 +-
crates/call/src/call.rs                            |  9 +++-
crates/call/src/participant.rs                     |  0 
crates/call/src/room.rs                            | 10 +---
crates/client/src/client.rs                        |  2 
crates/client/src/incoming_call.rs                 |  2 
crates/client/src/user.rs                          | 11 +++--
crates/collab/Cargo.toml                           |  2 
crates/collab/src/integration_tests.rs             |  2 
crates/collab_ui/Cargo.toml                        |  6 +-
crates/collab_ui/src/contacts_popover.rs           |  2 
crates/collab_ui/src/incoming_call_notification.rs | 12 ++++--
13 files changed, 49 insertions(+), 43 deletions(-)

Detailed changes

Cargo.lock 🔗

@@ -684,6 +684,19 @@ version = "1.2.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "c1db59621ec70f09c5e9b597b220c7a2b43611f4710dc03ceb8748637775692c"
 
+[[package]]
+name = "call"
+version = "0.1.0"
+dependencies = [
+ "anyhow",
+ "client",
+ "collections",
+ "futures",
+ "gpui",
+ "project",
+ "util",
+]
+
 [[package]]
 name = "cap-fs-ext"
 version = "0.24.4"
@@ -1019,6 +1032,7 @@ dependencies = [
  "axum",
  "axum-extra",
  "base64",
+ "call",
  "clap 3.2.8",
  "client",
  "collections",
@@ -1040,7 +1054,6 @@ dependencies = [
  "prometheus",
  "rand 0.8.5",
  "reqwest",
- "room",
  "rpc",
  "scrypt",
  "serde",
@@ -1067,6 +1080,7 @@ name = "collab_ui"
 version = "0.1.0"
 dependencies = [
  "anyhow",
+ "call",
  "client",
  "clock",
  "collections",
@@ -1078,7 +1092,6 @@ dependencies = [
  "menu",
  "postage",
  "project",
- "room",
  "serde",
  "settings",
  "theme",
@@ -4452,19 +4465,6 @@ dependencies = [
  "librocksdb-sys",
 ]
 
-[[package]]
-name = "room"
-version = "0.1.0"
-dependencies = [
- "anyhow",
- "client",
- "collections",
- "futures",
- "gpui",
- "project",
- "util",
-]
-
 [[package]]
 name = "roxmltree"
 version = "0.14.1"

crates/room/Cargo.toml → crates/call/Cargo.toml 🔗

@@ -1,10 +1,10 @@
 [package]
-name = "room"
+name = "call"
 version = "0.1.0"
 edition = "2021"
 
 [lib]
-path = "src/room.rs"
+path = "src/call.rs"
 doctest = false
 
 [features]

crates/room/src/active_call.rs → crates/call/src/call.rs 🔗

@@ -1,7 +1,10 @@
-use crate::Room;
+mod participant;
+mod room;
+
 use anyhow::{anyhow, Result};
-use client::{call::Call, Client, UserStore};
+use client::{incoming_call::IncomingCall, Client, UserStore};
 use gpui::{Entity, ModelContext, ModelHandle, MutableAppContext, Task};
+pub use room::Room;
 use std::sync::Arc;
 use util::ResultExt;
 
@@ -49,7 +52,7 @@ impl ActiveCall {
 
     pub fn join(
         &mut self,
-        call: &Call,
+        call: &IncomingCall,
         client: &Arc<Client>,
         user_store: &ModelHandle<UserStore>,
         cx: &mut ModelContext<Self>,

crates/room/src/room.rs → crates/call/src/room.rs 🔗

@@ -1,13 +1,9 @@
-mod active_call;
-mod participant;
-
-pub use active_call::ActiveCall;
+use crate::participant::{LocalParticipant, ParticipantLocation, RemoteParticipant};
 use anyhow::{anyhow, Result};
-use client::{call::Call, proto, Client, PeerId, TypedEnvelope, User, UserStore};
+use client::{incoming_call::IncomingCall, proto, Client, PeerId, TypedEnvelope, User, UserStore};
 use collections::HashMap;
 use futures::StreamExt;
 use gpui::{AsyncAppContext, Entity, ModelContext, ModelHandle, MutableAppContext, Task};
-use participant::{LocalParticipant, ParticipantLocation, RemoteParticipant};
 use project::Project;
 use std::sync::Arc;
 use util::ResultExt;
@@ -81,7 +77,7 @@ impl Room {
     }
 
     pub fn join(
-        call: &Call,
+        call: &IncomingCall,
         client: Arc<Client>,
         user_store: ModelHandle<UserStore>,
         cx: &mut MutableAppContext,

crates/client/src/client.rs 🔗

@@ -1,9 +1,9 @@
 #[cfg(any(test, feature = "test-support"))]
 pub mod test;
 
-pub mod call;
 pub mod channel;
 pub mod http;
+pub mod incoming_call;
 pub mod user;
 
 use anyhow::{anyhow, Context, Result};

crates/client/src/call.rs → crates/client/src/incoming_call.rs 🔗

@@ -2,7 +2,7 @@ use crate::User;
 use std::sync::Arc;
 
 #[derive(Clone)]
-pub struct Call {
+pub struct IncomingCall {
     pub room_id: u64,
     pub caller: Arc<User>,
     pub participants: Vec<Arc<User>>,

crates/client/src/user.rs 🔗

@@ -1,5 +1,5 @@
 use super::{http::HttpClient, proto, Client, Status, TypedEnvelope};
-use crate::call::Call;
+use crate::incoming_call::IncomingCall;
 use anyhow::{anyhow, Context, Result};
 use collections::{hash_map::Entry, BTreeSet, HashMap, HashSet};
 use futures::{channel::mpsc, future, AsyncReadExt, Future, StreamExt};
@@ -67,7 +67,10 @@ pub struct UserStore {
     outgoing_contact_requests: Vec<Arc<User>>,
     pending_contact_requests: HashMap<u64, usize>,
     invite_info: Option<InviteInfo>,
-    incoming_call: (watch::Sender<Option<Call>>, watch::Receiver<Option<Call>>),
+    incoming_call: (
+        watch::Sender<Option<IncomingCall>>,
+        watch::Receiver<Option<IncomingCall>>,
+    ),
     client: Weak<Client>,
     http: Arc<dyn HttpClient>,
     _maintain_contacts: Task<()>,
@@ -205,7 +208,7 @@ impl UserStore {
         _: Arc<Client>,
         mut cx: AsyncAppContext,
     ) -> Result<proto::Ack> {
-        let call = Call {
+        let call = IncomingCall {
             room_id: envelope.payload.room_id,
             participants: this
                 .update(&mut cx, |this, cx| {
@@ -241,7 +244,7 @@ impl UserStore {
         self.invite_info.as_ref()
     }
 
-    pub fn incoming_call(&self) -> watch::Receiver<Option<Call>> {
+    pub fn incoming_call(&self) -> watch::Receiver<Option<IncomingCall>> {
         self.incoming_call.1.clone()
     }
 

crates/collab/Cargo.toml 🔗

@@ -55,13 +55,13 @@ features = ["runtime-tokio-rustls", "postgres", "time", "uuid"]
 [dev-dependencies]
 collections = { path = "../collections", features = ["test-support"] }
 gpui = { path = "../gpui", features = ["test-support"] }
+call = { path = "../call", features = ["test-support"] }
 client = { path = "../client", features = ["test-support"] }
 editor = { path = "../editor", features = ["test-support"] }
 language = { path = "../language", features = ["test-support"] }
 log = { version = "0.4.16", features = ["kv_unstable_serde"] }
 lsp = { path = "../lsp", features = ["test-support"] }
 project = { path = "../project", features = ["test-support"] }
-room = { path = "../room", features = ["test-support"] }
 rpc = { path = "../rpc", features = ["test-support"] }
 settings = { path = "../settings", features = ["test-support"] }
 theme = { path = "../theme" }

crates/collab/src/integration_tests.rs 🔗

@@ -5,6 +5,7 @@ use crate::{
 };
 use ::rpc::Peer;
 use anyhow::anyhow;
+use call::Room;
 use client::{
     self, proto, test::FakeHttpClient, Channel, ChannelDetails, ChannelList, Client, Connection,
     Credentials, EstablishConnectionError, ProjectMetadata, UserStore, RECEIVE_TIMEOUT,
@@ -34,7 +35,6 @@ use project::{
     DiagnosticSummary, Project, ProjectPath, ProjectStore, WorktreeId,
 };
 use rand::prelude::*;
-use room::Room;
 use rpc::PeerId;
 use serde_json::json;
 use settings::{Formatter, Settings};

crates/collab_ui/Cargo.toml 🔗

@@ -9,18 +9,19 @@ doctest = false
 
 [features]
 test-support = [
+    "call/test-support",
     "client/test-support",
     "collections/test-support",
     "editor/test-support",
     "gpui/test-support",
     "project/test-support",
-    "room/test-support",
     "settings/test-support",
     "util/test-support",
     "workspace/test-support",
 ]
 
 [dependencies]
+call = { path = "../call" }
 client = { path = "../client" }
 clock = { path = "../clock" }
 collections = { path = "../collections" }
@@ -29,7 +30,6 @@ fuzzy = { path = "../fuzzy" }
 gpui = { path = "../gpui" }
 menu = { path = "../menu" }
 project = { path = "../project" }
-room = { path = "../room" }
 settings = { path = "../settings" }
 theme = { path = "../theme" }
 util = { path = "../util" }
@@ -41,12 +41,12 @@ postage = { version = "0.4.1", features = ["futures-traits"] }
 serde = { version = "1.0", features = ["derive", "rc"] }
 
 [dev-dependencies]
+call = { path = "../call", features = ["test-support"] }
 client = { path = "../client", features = ["test-support"] }
 collections = { path = "../collections", features = ["test-support"] }
 editor = { path = "../editor", features = ["test-support"] }
 gpui = { path = "../gpui", features = ["test-support"] }
 project = { path = "../project", features = ["test-support"] }
-room = { path = "../room", features = ["test-support"] }
 settings = { path = "../settings", features = ["test-support"] }
 util = { path = "../util", features = ["test-support"] }
 workspace = { path = "../workspace", features = ["test-support"] }

crates/collab_ui/src/contacts_popover.rs 🔗

@@ -1,5 +1,6 @@
 use std::sync::Arc;
 
+use call::ActiveCall;
 use client::{Client, Contact, User, UserStore};
 use editor::{Cancel, Editor};
 use fuzzy::{match_strings, StringMatchCandidate};
@@ -9,7 +10,6 @@ use gpui::{
     ViewHandle,
 };
 use menu::{Confirm, SelectNext, SelectPrev};
-use room::ActiveCall;
 use settings::Settings;
 use theme::IconButton;
 

crates/collab_ui/src/incoming_call_notification.rs 🔗

@@ -1,6 +1,7 @@
 use std::sync::Arc;
 
-use client::{call::Call, Client, UserStore};
+use call::ActiveCall;
+use client::{incoming_call::IncomingCall, Client, UserStore};
 use futures::StreamExt;
 use gpui::{
     elements::*,
@@ -8,7 +9,6 @@ use gpui::{
     impl_internal_actions, Entity, ModelHandle, MouseButton, MutableAppContext, RenderContext,
     View, ViewContext, WindowBounds, WindowKind, WindowOptions,
 };
-use room::ActiveCall;
 use settings::Settings;
 use util::ResultExt;
 
@@ -55,13 +55,17 @@ struct RespondToCall {
 }
 
 pub struct IncomingCallNotification {
-    call: Call,
+    call: IncomingCall,
     client: Arc<Client>,
     user_store: ModelHandle<UserStore>,
 }
 
 impl IncomingCallNotification {
-    pub fn new(call: Call, client: Arc<Client>, user_store: ModelHandle<UserStore>) -> Self {
+    pub fn new(
+        call: IncomingCall,
+        client: Arc<Client>,
+        user_store: ModelHandle<UserStore>,
+    ) -> Self {
         Self {
             call,
             client,