mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
27 lines
682 B
Rust
27 lines
682 B
Rust
use std::path::PathBuf;
|
|
|
|
use yazi_shared::scheme::{AsScheme, Scheme, SchemeRef};
|
|
|
|
use crate::Xdg;
|
|
|
|
pub trait FsScheme {
|
|
fn cache(&self) -> Option<PathBuf>;
|
|
}
|
|
|
|
impl FsScheme for SchemeRef<'_> {
|
|
fn cache(&self) -> Option<PathBuf> {
|
|
match self {
|
|
Self::Regular { .. } | Self::Search { .. } => None,
|
|
Self::Archive { domain, .. } => Some(
|
|
Xdg::temp_dir().join(format!("archive-{}", yazi_shared::scheme::Encode::domain(domain))),
|
|
),
|
|
Self::Sftp { domain, .. } => {
|
|
Some(Xdg::temp_dir().join(format!("sftp-{}", yazi_shared::scheme::Encode::domain(domain))))
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
impl FsScheme for Scheme {
|
|
fn cache(&self) -> Option<PathBuf> { self.as_scheme().cache() }
|
|
}
|