
For future reference: WIP branch of copy/pasting a mixture of images and text: https://github.com/zed-industries/zed/tree/copy-paste-images - we'll come back to that one after landing this one. Release Notes: - You can now paste images into the Assistant Panel to include them as context. Currently works only on Mac, and with Anthropic models. Future support is planned for more models, operating systems, and image clipboard operations. --------- Co-authored-by: Antonio <antonio@zed.dev> Co-authored-by: Mikayla <mikayla@zed.dev> Co-authored-by: Jason <jason@zed.dev> Co-authored-by: Kyle <kylek@zed.dev>
46 lines
1.1 KiB
Rust
46 lines
1.1 KiB
Rust
use crate::{AppContext, SharedString, SharedUri};
|
|
use futures::Future;
|
|
use std::hash::{Hash, Hasher};
|
|
use std::path::PathBuf;
|
|
use std::sync::Arc;
|
|
|
|
#[derive(Debug, PartialEq, Eq, Hash, Clone)]
|
|
pub(crate) enum UriOrPath {
|
|
Uri(SharedUri),
|
|
Path(Arc<PathBuf>),
|
|
Embedded(SharedString),
|
|
}
|
|
|
|
impl From<SharedUri> for UriOrPath {
|
|
fn from(value: SharedUri) -> Self {
|
|
Self::Uri(value)
|
|
}
|
|
}
|
|
|
|
impl From<Arc<PathBuf>> for UriOrPath {
|
|
fn from(value: Arc<PathBuf>) -> Self {
|
|
Self::Path(value)
|
|
}
|
|
}
|
|
|
|
/// A trait for asynchronous asset loading.
|
|
pub trait Asset {
|
|
/// The source of the asset.
|
|
type Source: Clone + Hash + Send;
|
|
|
|
/// The loaded asset
|
|
type Output: Clone + Send;
|
|
|
|
/// Load the asset asynchronously
|
|
fn load(
|
|
source: Self::Source,
|
|
cx: &mut AppContext,
|
|
) -> impl Future<Output = Self::Output> + Send + 'static;
|
|
}
|
|
|
|
/// Use a quick, non-cryptographically secure hash function to get an identifier from data
|
|
pub fn hash<T: Hash>(data: &T) -> u64 {
|
|
let mut hasher = collections::FxHasher::default();
|
|
data.hash(&mut hasher);
|
|
hasher.finish()
|
|
}
|