#[cfg(test)]
mod tests;
use std::path::Path;
#[derive(Debug, Clone, PartialEq)]
pub struct ManifestDependencyConfig<'a> {
pub origin: ManifestDependencyOrigin<'a>,
pub default_features: bool,
pub features: Vec<&'a str>,
pub optional: bool,
}
impl<'a> ManifestDependencyConfig<'a> {
pub fn new(
origin: ManifestDependencyOrigin<'a>,
default_features: bool,
features: Vec<&'a str>,
optional: bool,
) -> Self {
Self { origin, default_features, features, optional }
}
pub fn add_features(&mut self, features: &[&'a str]) {
self.features.extend_from_slice(features);
}
}
#[derive(Debug, Clone, PartialEq)]
pub enum ManifestDependencyOrigin<'a> {
CratesIO { version: &'a str },
Git { url: &'a str, branch: &'a str },
Local { relative_path: &'a Path },
Workspace,
}
impl<'a> ManifestDependencyOrigin<'a> {
pub fn crates_io(version: &'a str) -> Self {
Self::CratesIO { version }
}
pub fn git(url: &'a str, branch: &'a str) -> Self {
Self::Git { url, branch }
}
pub fn local(relative_path: &'a Path) -> Self {
Self::Local { relative_path }
}
pub fn workspace() -> Self {
Self::Workspace
}
}