wasmer_package/package/
strictness.rsuse std::{fmt::Debug, path::Path};
use anyhow::Error;
use super::ManifestError;
#[derive(Debug, Default, Copy, Clone, PartialEq)]
pub enum Strictness {
#[default]
Lossy,
Strict,
}
impl Strictness {
pub(crate) fn is_strict(self) -> bool {
matches!(self, Strictness::Strict)
}
pub(crate) fn on_error(&self, _path: &Path, error: Error) -> Result<(), Error> {
match self {
Strictness::Lossy => Ok(()),
Strictness::Strict => Err(error),
}
}
pub(crate) fn outside_base_directory(
&self,
path: &Path,
base_dir: &Path,
) -> Result<(), ManifestError> {
match self {
Strictness::Lossy => todo!(),
Strictness::Strict => Err(ManifestError::OutsideBaseDirectory {
path: path.to_path_buf(),
base_dir: base_dir.to_path_buf(),
}),
}
}
pub(crate) fn missing_file(&self, path: &Path, base_dir: &Path) -> Result<(), ManifestError> {
match self {
Strictness::Lossy => Ok(()),
Strictness::Strict => Err(ManifestError::MissingFile {
path: path.to_path_buf(),
base_dir: base_dir.to_path_buf(),
}),
}
}
}