summaryrefslogtreecommitdiff
path: root/src/project.rs
blob: 7471c6672dfd646a1af33a6ba66cb52b558182a8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
use crate::errors::BumperError;
use crate::rust::Rust;
use std::path::Path;

pub enum ProjectKind {
    Rust(Rust),
}

impl ProjectKind {
    pub fn detect<P: AsRef<Path>>(dirname: P) -> Result<ProjectKind, BumperError> {
        let dirname = dirname.as_ref();

        if let Ok(p) = Rust::new(dirname) {
            return Ok(Self::Rust(p));
        }

        Err(BumperError::UnknownProjectKind(dirname.to_path_buf()))
    }

    pub fn set_version(&mut self, version: &str) -> Result<(), BumperError> {
        match self {
            Self::Rust(ref mut rust) => rust.set_version(version)?,
        }
        Ok(())
    }
}