yazi_config/plugin/
fetcher.rs

1use std::path::Path;
2
3use serde::Deserialize;
4use yazi_shared::{MIME_DIR, event::Cmd};
5
6use crate::{Pattern, Priority};
7
8#[derive(Debug, Deserialize)]
9pub struct Fetcher {
10	#[serde(skip)]
11	pub idx: u8,
12
13	pub id:   String,
14	pub name: Option<Pattern>,
15	pub mime: Option<Pattern>,
16	pub run:  Cmd,
17	#[serde(default)]
18	pub prio: Priority,
19}
20
21impl Fetcher {
22	#[inline]
23	pub fn matches(&self, path: &Path, mime: &str) -> bool {
24		self.mime.as_ref().is_some_and(|p| p.match_mime(mime))
25			|| self.name.as_ref().is_some_and(|p| p.match_path(path, mime == MIME_DIR))
26	}
27}