use super::Snapshot;
use crate::naming;
use std::path::{Path, PathBuf};
impl Snapshot {
fn ws_paths(&self) -> Vec<PathBuf> {
self.workspaces.iter().map(|w| w.path.clone()).collect()
}
pub fn ws_name(&self, path: &Path) -> String {
naming::leaf(path)
}
pub fn ws_path(&self, name: &str) -> Result<PathBuf, String> {
naming::by_leaf(&self.ws_paths(), name)
}
pub fn project_name(&self, path: &Path) -> String {
naming::name_of(&self.projects, path)
}
pub fn project_path(&self, name: &str) -> Result<PathBuf, String> {
naming::resolve(&self.projects, name)
}
}
#[cfg(test)]
mod tests;