diff --git a/crates/client/src/user.rs b/crates/client/src/user.rs index 23cd97994f..d6a60f5b4c 100644 --- a/crates/client/src/user.rs +++ b/crates/client/src/user.rs @@ -4,7 +4,7 @@ use collections::{hash_map::Entry, HashMap, HashSet}; use feature_flags::FeatureFlagAppExt; use futures::{channel::mpsc, Future, StreamExt}; use gpui::{ - AppContext, AsyncAppContext, EventEmitter, Model, ModelContext, SharedString, SharedUrl, Task, + AppContext, AsyncAppContext, EventEmitter, Model, ModelContext, SharedString, SharedUri, Task, WeakModel, }; use postage::{sink::Sink, watch}; @@ -22,7 +22,7 @@ pub struct ParticipantIndex(pub u32); pub struct User { pub id: UserId, pub github_login: String, - pub avatar_uri: SharedUrl, + pub avatar_uri: SharedUri, } #[derive(Clone, Debug, PartialEq, Eq)] @@ -707,7 +707,7 @@ impl User { Arc::new(User { id: message.id, github_login: message.github_login, - avatar_uri: SharedUrl::network(message.avatar_url), + avatar_uri: SharedUri::network(message.avatar_url), }) } } diff --git a/crates/collab/src/tests/integration_tests.rs b/crates/collab/src/tests/integration_tests.rs index 6dd1751c8c..0d9a64e511 100644 --- a/crates/collab/src/tests/integration_tests.rs +++ b/crates/collab/src/tests/integration_tests.rs @@ -9,7 +9,7 @@ use fs::{repository::GitFileStatus, FakeFs, Fs as _, RemoveOptions}; use futures::StreamExt as _; use gpui::{ px, size, AppContext, BackgroundExecutor, Model, Modifiers, MouseButton, MouseDownEvent, - SharedUrl, TestAppContext, + SharedUri, TestAppContext, }; use language::{ language_settings::{AllLanguageSettings, Formatter}, @@ -1828,7 +1828,7 @@ async fn test_active_call_events( owner: Arc::new(User { id: client_a.user_id().unwrap(), github_login: "user_a".to_string(), - avatar_uri: SharedUrl::network("avatar_a"), + avatar_uri: SharedUri::network("avatar_a"), }), project_id: project_a_id, worktree_root_names: vec!["a".to_string()], @@ -1846,7 +1846,7 @@ async fn test_active_call_events( owner: Arc::new(User { id: client_b.user_id().unwrap(), github_login: "user_b".to_string(), - avatar_uri: SharedUrl::network("avatar_b"), + avatar_uri: SharedUri::network("avatar_b"), }), project_id: project_b_id, worktree_root_names: vec!["b".to_string()] diff --git a/crates/collab_ui/src/chat_panel.rs b/crates/collab_ui/src/chat_panel.rs index 14fab4301b..879ff67d63 100644 --- a/crates/collab_ui/src/chat_panel.rs +++ b/crates/collab_ui/src/chat_panel.rs @@ -714,7 +714,7 @@ fn format_timestamp( #[cfg(test)] mod tests { use super::*; - use gpui::{HighlightStyle, SharedUrl}; + use gpui::{HighlightStyle, SharedUri}; use pretty_assertions::assert_eq; use rich_text::Highlight; use time::{Date, OffsetDateTime, Time, UtcOffset}; @@ -730,7 +730,7 @@ mod tests { timestamp: OffsetDateTime::now_utc(), sender: Arc::new(client::User { github_login: "fgh".into(), - avatar_uri: SharedUrl::network("avatar_fgh"), + avatar_uri: SharedUri::network("avatar_fgh"), id: 103, }), nonce: 5, diff --git a/crates/collab_ui/src/chat_panel/message_editor.rs b/crates/collab_ui/src/chat_panel/message_editor.rs index 48cf4ab405..701ecd8e8e 100644 --- a/crates/collab_ui/src/chat_panel/message_editor.rs +++ b/crates/collab_ui/src/chat_panel/message_editor.rs @@ -365,7 +365,7 @@ impl Render for MessageEditor { mod tests { use super::*; use client::{Client, User, UserStore}; - use gpui::{SharedUrl, TestAppContext}; + use gpui::{SharedUri, TestAppContext}; use language::{Language, LanguageConfig}; use rpc::proto; use settings::SettingsStore; @@ -392,7 +392,7 @@ mod tests { user: Arc::new(User { github_login: "a-b".into(), id: 101, - avatar_uri: SharedUrl::network("avatar_a-b"), + avatar_uri: SharedUri::network("avatar_a-b"), }), kind: proto::channel_member::Kind::Member, role: proto::ChannelRole::Member, @@ -401,7 +401,7 @@ mod tests { user: Arc::new(User { github_login: "C_D".into(), id: 102, - avatar_uri: SharedUrl::network("avatar_C_D"), + avatar_uri: SharedUri::network("avatar_C_D"), }), kind: proto::channel_member::Kind::Member, role: proto::ChannelRole::Member, diff --git a/crates/collab_ui/src/notifications/collab_notification.rs b/crates/collab_ui/src/notifications/collab_notification.rs index 69d26e50fd..97b7100106 100644 --- a/crates/collab_ui/src/notifications/collab_notification.rs +++ b/crates/collab_ui/src/notifications/collab_notification.rs @@ -1,10 +1,10 @@ -use gpui::{img, prelude::*, AnyElement, SharedUrl}; +use gpui::{img, prelude::*, AnyElement, SharedUri}; use smallvec::SmallVec; use ui::prelude::*; #[derive(IntoElement)] pub struct CollabNotification { - avatar_uri: SharedUrl, + avatar_uri: SharedUri, accept_button: Button, dismiss_button: Button, children: SmallVec<[AnyElement; 2]>, @@ -12,7 +12,7 @@ pub struct CollabNotification { impl CollabNotification { pub fn new( - avatar_uri: impl Into, + avatar_uri: impl Into, accept_button: Button, dismiss_button: Button, ) -> Self { diff --git a/crates/collab_ui/src/notifications/stories/collab_notification.rs b/crates/collab_ui/src/notifications/stories/collab_notification.rs index e04a7b3904..55700ca6f0 100644 --- a/crates/collab_ui/src/notifications/stories/collab_notification.rs +++ b/crates/collab_ui/src/notifications/stories/collab_notification.rs @@ -1,4 +1,4 @@ -use gpui::{prelude::*, SharedUrl}; +use gpui::{prelude::*, SharedUri}; use story::{StoryContainer, StoryItem, StorySection}; use ui::prelude::*; @@ -19,7 +19,7 @@ impl Render for CollabNotificationStory { "Incoming Call Notification", window_container(400., 72.).child( CollabNotification::new( - SharedUrl::network("https://avatars.githubusercontent.com/u/1486634?v=4"), + SharedUri::network("https://avatars.githubusercontent.com/u/1486634?v=4"), Button::new("accept", "Accept"), Button::new("decline", "Decline"), ) @@ -36,7 +36,7 @@ impl Render for CollabNotificationStory { "Project Shared Notification", window_container(400., 72.).child( CollabNotification::new( - SharedUrl::network("https://avatars.githubusercontent.com/u/1714999?v=4"), + SharedUri::network("https://avatars.githubusercontent.com/u/1714999?v=4"), Button::new("open", "Open"), Button::new("dismiss", "Dismiss"), ) diff --git a/crates/gpui/examples/image.rs b/crates/gpui/examples/image.rs index 01a9cfb435..f0bb371bad 100644 --- a/crates/gpui/examples/image.rs +++ b/crates/gpui/examples/image.rs @@ -3,7 +3,7 @@ use gpui::*; #[derive(IntoElement)] struct ImageFromResource { text: SharedString, - resource: SharedUrl, + resource: SharedUri, } impl RenderOnce for ImageFromResource { @@ -20,8 +20,8 @@ impl RenderOnce for ImageFromResource { } struct ImageShowcase { - local_resource: SharedUrl, - remote_resource: SharedUrl, + local_resource: SharedUri, + remote_resource: SharedUri, } impl Render for ImageShowcase { @@ -51,8 +51,8 @@ fn main() { App::new().run(|cx: &mut AppContext| { cx.open_window(WindowOptions::default(), |cx| { cx.new_view(|_cx| ImageShowcase { - local_resource: SharedUrl::file("../zed/resources/app-icon.png"), - remote_resource: SharedUrl::network("https://picsum.photos/512/512"), + local_resource: SharedUri::file("../zed/resources/app-icon.png"), + remote_resource: SharedUri::network("https://picsum.photos/512/512"), }) }); }); diff --git a/crates/gpui/src/elements/img.rs b/crates/gpui/src/elements/img.rs index d1455d33d6..00804fe565 100644 --- a/crates/gpui/src/elements/img.rs +++ b/crates/gpui/src/elements/img.rs @@ -2,7 +2,7 @@ use std::sync::Arc; use crate::{ point, size, Bounds, DevicePixels, Element, ElementContext, ImageData, InteractiveElement, - InteractiveElementState, Interactivity, IntoElement, LayoutId, Pixels, SharedUrl, Size, + InteractiveElementState, Interactivity, IntoElement, LayoutId, Pixels, SharedUri, Size, StyleRefinement, Styled, }; use futures::FutureExt; @@ -13,7 +13,7 @@ use util::ResultExt; #[derive(Clone, Debug)] pub enum ImageSource { /// Image content will be loaded from provided URI at render time. - Uri(SharedUrl), + Uri(SharedUri), /// Cached image data Data(Arc), // TODO: move surface definitions into mac platform module @@ -21,8 +21,8 @@ pub enum ImageSource { Surface(CVImageBuffer), } -impl From for ImageSource { - fn from(value: SharedUrl) -> Self { +impl From for ImageSource { + fn from(value: SharedUri) -> Self { Self::Uri(value) } } diff --git a/crates/gpui/src/gpui.rs b/crates/gpui/src/gpui.rs index 638e94de39..36674b52bf 100644 --- a/crates/gpui/src/gpui.rs +++ b/crates/gpui/src/gpui.rs @@ -83,7 +83,7 @@ mod platform; pub mod prelude; mod scene; mod shared_string; -mod shared_url; +mod shared_uri; mod style; mod styled; mod subscription; @@ -133,7 +133,7 @@ pub use refineable::*; pub use scene::*; use seal::Sealed; pub use shared_string::*; -pub use shared_url::*; +pub use shared_uri::*; pub use smol::Timer; pub use style::*; pub use styled::*; diff --git a/crates/gpui/src/image_cache.rs b/crates/gpui/src/image_cache.rs index 318aea8265..3c9a1741ed 100644 --- a/crates/gpui/src/image_cache.rs +++ b/crates/gpui/src/image_cache.rs @@ -1,4 +1,4 @@ -use crate::{AppContext, ImageData, ImageId, SharedUrl, Task}; +use crate::{AppContext, ImageData, ImageId, SharedUri, Task}; use collections::HashMap; use futures::{future::Shared, AsyncReadExt, FutureExt, TryFutureExt}; use image::ImageError; @@ -41,7 +41,7 @@ impl From for Error { pub(crate) struct ImageCache { client: Arc, - images: Arc>>, + images: Arc>>, } type FetchImageTask = Shared, Error>>>; @@ -54,7 +54,7 @@ impl ImageCache { } } - pub fn get(&self, uri: impl Into, cx: &AppContext) -> FetchImageTask { + pub fn get(&self, uri: impl Into, cx: &AppContext) -> FetchImageTask { let uri = uri.into(); let mut images = self.images.lock(); @@ -69,11 +69,11 @@ impl ImageCache { let uri = uri.clone(); async move { match uri { - SharedUrl::File(uri) => { + SharedUri::File(uri) => { let image = image::open(uri.as_ref())?.into_bgra8(); Ok(Arc::new(ImageData::new(image))) } - SharedUrl::Network(uri) => { + SharedUri::Network(uri) => { let mut response = client.get(uri.as_ref(), ().into(), true).await?; let mut body = Vec::new(); diff --git a/crates/gpui/src/shared_url.rs b/crates/gpui/src/shared_uri.rs similarity index 75% rename from crates/gpui/src/shared_url.rs rename to crates/gpui/src/shared_uri.rs index d419482391..0784ea87ff 100644 --- a/crates/gpui/src/shared_url.rs +++ b/crates/gpui/src/shared_uri.rs @@ -2,34 +2,34 @@ use std::ops::{Deref, DerefMut}; use crate::SharedString; -/// A URL stored in a `SharedString` pointing to a file or a remote resource. +/// A URI stored in a [`SharedString`]. #[derive(PartialEq, Eq, Hash, Clone)] -pub enum SharedUrl { +pub enum SharedUri { /// A path to a local file. File(SharedString), /// A URL to a remote resource. Network(SharedString), } -impl SharedUrl { - /// Create a URL pointing to a local file. +impl SharedUri { + /// Creates a [`SharedUri`] pointing to a local file. pub fn file>(s: S) -> Self { Self::File(s.into()) } - /// Create a URL pointing to a remote resource. + /// Creates a [`SharedUri`] pointing to a remote resource. pub fn network>(s: S) -> Self { Self::Network(s.into()) } } -impl Default for SharedUrl { +impl Default for SharedUri { fn default() -> Self { Self::Network(SharedString::default()) } } -impl Deref for SharedUrl { +impl Deref for SharedUri { type Target = SharedString; fn deref(&self) -> &Self::Target { @@ -40,7 +40,7 @@ impl Deref for SharedUrl { } } -impl DerefMut for SharedUrl { +impl DerefMut for SharedUri { fn deref_mut(&mut self) -> &mut Self::Target { match self { Self::File(s) => s, @@ -49,7 +49,7 @@ impl DerefMut for SharedUrl { } } -impl std::fmt::Debug for SharedUrl { +impl std::fmt::Debug for SharedUri { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { Self::File(s) => write!(f, "File({:?})", s), @@ -58,7 +58,7 @@ impl std::fmt::Debug for SharedUrl { } } -impl std::fmt::Display for SharedUrl { +impl std::fmt::Display for SharedUri { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(f, "{}", self.as_ref()) } diff --git a/crates/theme/src/styles/stories/players.rs b/crates/theme/src/styles/stories/players.rs index 8963736e61..e9462cbbbb 100644 --- a/crates/theme/src/styles/stories/players.rs +++ b/crates/theme/src/styles/stories/players.rs @@ -1,4 +1,4 @@ -use gpui::{div, img, px, IntoElement, ParentElement, Render, SharedUrl, Styled, ViewContext}; +use gpui::{div, img, px, IntoElement, ParentElement, Render, SharedUri, Styled, ViewContext}; use story::Story; use crate::{ActiveTheme, PlayerColors}; @@ -53,7 +53,7 @@ impl Render for PlayerStory { .border_2() .border_color(player.cursor) .child( - img(SharedUrl::network( + img(SharedUri::network( "https://avatars.githubusercontent.com/u/1714999?v=4", )) .rounded_full() @@ -84,7 +84,7 @@ impl Render for PlayerStory { .border_color(player.background) .size(px(28.)) .child( - img(SharedUrl::network( + img(SharedUri::network( "https://avatars.githubusercontent.com/u/1714999?v=4", )) .rounded_full() @@ -102,7 +102,7 @@ impl Render for PlayerStory { .border_color(player.background) .size(px(28.)) .child( - img(SharedUrl::network( + img(SharedUri::network( "https://avatars.githubusercontent.com/u/1714999?v=4", )) .rounded_full() @@ -120,7 +120,7 @@ impl Render for PlayerStory { .border_color(player.background) .size(px(28.)) .child( - img(SharedUrl::network( + img(SharedUri::network( "https://avatars.githubusercontent.com/u/1714999?v=4", )) .rounded_full() diff --git a/crates/ui/src/components/stories/avatar.rs b/crates/ui/src/components/stories/avatar.rs index 5820d2b8c9..6a8f70a318 100644 --- a/crates/ui/src/components/stories/avatar.rs +++ b/crates/ui/src/components/stories/avatar.rs @@ -1,4 +1,4 @@ -use gpui::{Render, SharedUrl}; +use gpui::{Render, SharedUri}; use story::{StoryContainer, StoryItem, StorySection}; use crate::{prelude::*, AudioStatus, Availability, AvatarAvailabilityIndicator}; @@ -13,13 +13,13 @@ impl Render for AvatarStory { StorySection::new() .child(StoryItem::new( "Default", - Avatar::new(SharedUrl::network( + Avatar::new(SharedUri::network( "https://avatars.githubusercontent.com/u/1714999?v=4", )), )) .child(StoryItem::new( "Default", - Avatar::new(SharedUrl::network( + Avatar::new(SharedUri::network( "https://avatars.githubusercontent.com/u/326587?v=4", )), )), @@ -28,14 +28,14 @@ impl Render for AvatarStory { StorySection::new() .child(StoryItem::new( "With free availability indicator", - Avatar::new(SharedUrl::network( + Avatar::new(SharedUri::network( "https://avatars.githubusercontent.com/u/326587?v=4", )) .indicator(AvatarAvailabilityIndicator::new(Availability::Free)), )) .child(StoryItem::new( "With busy availability indicator", - Avatar::new(SharedUrl::network( + Avatar::new(SharedUri::network( "https://avatars.githubusercontent.com/u/326587?v=4", )) .indicator(AvatarAvailabilityIndicator::new(Availability::Busy)), @@ -45,14 +45,14 @@ impl Render for AvatarStory { StorySection::new() .child(StoryItem::new( "With info border", - Avatar::new(SharedUrl::network( + Avatar::new(SharedUri::network( "https://avatars.githubusercontent.com/u/326587?v=4", )) .border_color(cx.theme().status().info_border), )) .child(StoryItem::new( "With error border", - Avatar::new(SharedUrl::network( + Avatar::new(SharedUri::network( "https://avatars.githubusercontent.com/u/326587?v=4", )) .border_color(cx.theme().status().error_border), @@ -62,14 +62,14 @@ impl Render for AvatarStory { StorySection::new() .child(StoryItem::new( "With muted audio indicator", - Avatar::new(SharedUrl::network( + Avatar::new(SharedUri::network( "https://avatars.githubusercontent.com/u/326587?v=4", )) .indicator(AvatarAudioStatusIndicator::new(AudioStatus::Muted)), )) .child(StoryItem::new( "With deafened audio indicator", - Avatar::new(SharedUrl::network( + Avatar::new(SharedUri::network( "https://avatars.githubusercontent.com/u/326587?v=4", )) .indicator(AvatarAudioStatusIndicator::new(AudioStatus::Deafened)), diff --git a/crates/ui/src/components/stories/list_item.rs b/crates/ui/src/components/stories/list_item.rs index 014b56b422..b0bf579fc5 100644 --- a/crates/ui/src/components/stories/list_item.rs +++ b/crates/ui/src/components/stories/list_item.rs @@ -1,4 +1,4 @@ -use gpui::{Render, SharedUrl}; +use gpui::{Render, SharedUri}; use story::Story; use crate::{prelude::*, Avatar}; @@ -45,7 +45,7 @@ impl Render for ListItemStory { .child( ListItem::new("with_start slot avatar") .child("Hello, world!") - .start_slot(Avatar::new(SharedUrl::network( + .start_slot(Avatar::new(SharedUri::network( "https://avatars.githubusercontent.com/u/1714999?v=4", ))), ) @@ -53,7 +53,7 @@ impl Render for ListItemStory { .child( ListItem::new("with_left_avatar") .child("Hello, world!") - .end_slot(Avatar::new(SharedUrl::network( + .end_slot(Avatar::new(SharedUri::network( "https://avatars.githubusercontent.com/u/1714999?v=4", ))), ) @@ -64,23 +64,23 @@ impl Render for ListItemStory { .end_slot( h_flex() .gap_2() - .child(Avatar::new(SharedUrl::network( + .child(Avatar::new(SharedUri::network( "https://avatars.githubusercontent.com/u/1789?v=4", ))) - .child(Avatar::new(SharedUrl::network( + .child(Avatar::new(SharedUri::network( "https://avatars.githubusercontent.com/u/1789?v=4", ))) - .child(Avatar::new(SharedUrl::network( + .child(Avatar::new(SharedUri::network( "https://avatars.githubusercontent.com/u/1789?v=4", ))) - .child(Avatar::new(SharedUrl::network( + .child(Avatar::new(SharedUri::network( "https://avatars.githubusercontent.com/u/1789?v=4", ))) - .child(Avatar::new(SharedUrl::network( + .child(Avatar::new(SharedUri::network( "https://avatars.githubusercontent.com/u/1789?v=4", ))), ) - .end_hover_slot(Avatar::new(SharedUrl::network( + .end_hover_slot(Avatar::new(SharedUri::network( "https://avatars.githubusercontent.com/u/1714999?v=4", ))), )