ayun_path/
instance.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use crate::Path;
use ayun_core::{errors::ContainerError, traits::InstanceTrait, Container, Result};

impl InstanceTrait for Path {
    fn register(_: &Container) -> Result<Self, ContainerError>
    where
        Self: Sized,
    {
        let base_path = std::env::var("CARGO_MANIFEST_DIR")
            .map(std::path::PathBuf::from)
            .unwrap_or_else(|_| {
                std::env::current_dir()
                    .expect("project directory does not exist or permissions are insufficient")
            });

        Ok(Self::new(base_path))
    }
}