wasmer_package/package/
strictness.rs1use std::{fmt::Debug, path::Path};
2
3use super::ManifestError;
4
5#[derive(Debug, Default, Copy, Clone, PartialEq)]
12pub enum Strictness {
13 #[default]
15 Lossy,
16 Strict,
18}
19
20impl Strictness {
21 pub(crate) fn is_strict(self) -> bool {
22 matches!(self, Strictness::Strict)
23 }
24
25 pub(crate) fn outside_base_directory(
26 &self,
27 path: &Path,
28 base_dir: &Path,
29 ) -> Result<(), ManifestError> {
30 match self {
31 Strictness::Lossy => todo!(),
32 Strictness::Strict => Err(ManifestError::OutsideBaseDirectory {
33 path: path.to_path_buf(),
34 base_dir: base_dir.to_path_buf(),
35 }),
36 }
37 }
38
39 pub(crate) fn missing_file(&self, path: &Path, base_dir: &Path) -> Result<(), ManifestError> {
40 match self {
41 Strictness::Lossy => Ok(()),
42 Strictness::Strict => Err(ManifestError::MissingFile {
43 path: path.to_path_buf(),
44 base_dir: base_dir.to_path_buf(),
45 }),
46 }
47 }
48}