Files
raven/retired/nest_lib_rs_old/lib.rs
2026-02-15 09:36:04 -05:00

46 lines
1.1 KiB
Rust

mod class;
mod dependency;
mod error;
//mod lock;
mod meta;
mod nest;
mod package;
pub mod prelude;
mod prey;
mod workspace;
pub use error::{Error, Result};
use std::io;
use std::path::PathBuf;
pub const FN_NEST: &str = "Nest";
pub const FN_PREY: &str = "Prey";
pub const F_NEST_TOML: &str = const_format::concatcp!(FN_NEST, fs::EXT_TOML);
pub const F_NEST_LOCK: &str = const_format::concatcp!(FN_NEST, fs::EXT_LOCK);
pub const F_PREY_TOML: &str = const_format::concatcp!(FN_PREY, fs::EXT_TOML);
pub const F_PREY_LOCK: &str = const_format::concatcp!(FN_PREY, fs::EXT_LOCK);
/// Return the location of the parent `Nest.toml` as [`PathBuf`]
///
/// # Errors
///
/// Possible cases:
///
/// * `Nest.toml` cannot be located.
/// * Current working directory does not exist.
/// * There are insufficient permissions to access the current directory.
pub fn locate_nest() -> io::Result<PathBuf> {
let cwd = std::env::current_dir()?;
let mut probe = cwd.clone();
while !probe.join(F_NEST_TOML).exists() {
if !probe.pop() {
return Err(io::ErrorKind::NotFound.into());
}
}
Ok(probe)
}