Rename SharedUrl
to SharedUri
(#7084)
This PR renames `SharedUrl` to `SharedUri` to better reflect its intent. I'm still not entirely happy with this naming, as the file paths that we can store in here are not _really_ URIs, as they are lacking a protocol. I want to explore changing `SharedUri` / `SharedUrl` back to alway storing a URL and treat local filepaths differently, as it seems we're conflating two different concerns under the same umbrella, at the moment. Release Notes: - N/A
This commit is contained in:
parent
d18c0d9df0
commit
6c7893db35
14 changed files with 66 additions and 66 deletions
|
@ -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<ImageError> for Error {
|
|||
|
||||
pub(crate) struct ImageCache {
|
||||
client: Arc<dyn HttpClient>,
|
||||
images: Arc<Mutex<HashMap<SharedUrl, FetchImageTask>>>,
|
||||
images: Arc<Mutex<HashMap<SharedUri, FetchImageTask>>>,
|
||||
}
|
||||
|
||||
type FetchImageTask = Shared<Task<Result<Arc<ImageData>, Error>>>;
|
||||
|
@ -54,7 +54,7 @@ impl ImageCache {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn get(&self, uri: impl Into<SharedUrl>, cx: &AppContext) -> FetchImageTask {
|
||||
pub fn get(&self, uri: impl Into<SharedUri>, 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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue