ayun_path/instance.rs
1use crate::Path;
2use ayun_core::{errors::ContainerError, traits::InstanceTrait, Container, Result};
3
4impl InstanceTrait for Path {
5 fn register(_: &Container) -> Result<Self, ContainerError>
6 where
7 Self: Sized,
8 {
9 let base_path = std::env::var("CARGO_MANIFEST_DIR")
10 .map(std::path::PathBuf::from)
11 .unwrap_or_else(|_| {
12 std::env::current_dir()
13 .expect("project directory does not exist or permissions are insufficient")
14 });
15
16 Ok(Self::new(base_path))
17 }
18}