ayun-path 0.22.0

The RUST Framework for Web Rustceans.
Documentation
mod instance;

#[derive(Debug)]
pub struct Path {
    inner: std::path::PathBuf,
}

impl Path {
    fn new(path: std::path::PathBuf) -> Self {
        Self { inner: path }
    }

    pub fn base(&self, path: &str) -> std::path::PathBuf {
        self.inner.join(path)
    }
}

impl std::ops::Deref for Path {
    type Target = std::path::PathBuf;

    fn deref(&self) -> &Self::Target {
        &self.inner
    }
}

impl std::fmt::Display for Path {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        self.to_string_lossy().fmt(f)
    }
}

pub fn base_path(str: &str) -> ayun_core::Result<std::path::PathBuf> {
    Ok(ayun_core::app().resolve::<Path>()?.base(str))
}