use std::path::PathBuf;
use crate::manifest::{PluginManifest, ResolvedComponents};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum PluginSource {
Project,
User,
Managed,
}
impl PluginSource {
#[must_use]
pub fn as_str(self) -> &'static str {
match self {
Self::Project => "project",
Self::User => "user",
Self::Managed => "managed",
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct NamespacedItem {
pub namespaced: String,
pub bare: String,
pub plugin: String,
}
impl NamespacedItem {
#[must_use]
pub fn new(plugin: &str, bare: &str) -> Self {
Self {
namespaced: format!("{plugin}:{bare}"),
bare: bare.to_string(),
plugin: plugin.to_string(),
}
}
}
#[derive(Debug, Clone)]
pub struct LoadedPlugin {
pub manifest: PluginManifest,
pub root_dir: PathBuf,
pub namespace: String,
pub source: PluginSource,
pub components: ResolvedComponents,
}
impl LoadedPlugin {
#[must_use]
pub fn namespace_item(&self, bare: &str) -> String {
format!("{}:{bare}", self.namespace)
}
}