rustilities/manifest/
types.rs1#[cfg(test)]
4mod tests;
5
6use std::path::Path;
7
8#[derive(Debug, Clone, PartialEq)]
10pub struct ManifestDependencyConfig<'a> {
11 pub origin: ManifestDependencyOrigin<'a>,
12 pub default_features: bool,
13 pub features: Vec<&'a str>,
14 pub optional: bool,
15}
16
17impl<'a> ManifestDependencyConfig<'a> {
18 pub fn new(
24 origin: ManifestDependencyOrigin<'a>,
25 default_features: bool,
26 features: Vec<&'a str>,
27 optional: bool,
28 ) -> Self {
29 Self { origin, default_features, features, optional }
30 }
31
32 pub fn add_features(&mut self, features: &[&'a str]) {
34 self.features.extend_from_slice(features);
35 }
36}
37
38#[derive(Debug, Clone, PartialEq)]
40pub enum ManifestDependencyOrigin<'a> {
41 CratesIO { version: &'a str },
42 Git { url: &'a str, branch: &'a str },
43 Local { relative_path: &'a Path },
44 Workspace,
45}
46
47impl<'a> ManifestDependencyOrigin<'a> {
48 pub fn crates_io(version: &'a str) -> Self {
50 Self::CratesIO { version }
51 }
52
53 pub fn git(url: &'a str, branch: &'a str) -> Self {
55 Self::Git { url, branch }
56 }
57
58 pub fn local(relative_path: &'a Path) -> Self {
60 Self::Local { relative_path }
61 }
62
63 pub fn workspace() -> Self {
65 Self::Workspace
66 }
67}