comtrya_lib/manifests/providers/
mod.rs

1mod local;
2use local::LocalManifestProvider;
3use std::path::PathBuf;
4mod git;
5use git::GitManifestProvider;
6
7pub fn register_providers() -> Vec<Box<dyn ManifestProvider>> {
8    vec![
9        Box::new(LocalManifestProvider),
10        Box::new(GitManifestProvider),
11    ]
12}
13
14#[derive(Debug, PartialEq, Eq)]
15pub enum ManifestProviderError {
16    NoResolution,
17}
18
19/// ManifestProviders are responsible for taking a String
20/// and returning a `PathBuf`. Providers, such as Git, are
21/// responsible for accepting the String and cloning the
22/// repository, in-order to return the `PathBuf`.
23pub trait ManifestProvider {
24    /// This functions is called to establish if it could potentially
25    /// be able to resolve the url provided
26    fn looks_familiar(&self, url: &str) -> bool;
27
28    /// This function is responsible for returning a PathBuf with
29    /// the directory containing the manifests
30    fn resolve(&self, url: &str) -> Result<PathBuf, ManifestProviderError>;
31}