pub mod host;
#[cfg_attr(docsrs, doc(cfg(feature = "nus")))]
#[cfg(feature = "nus")]
pub mod nus_fuse;
use std::path::PathBuf;
use valuable::{Fields, NamedField, NamedValues, StructDef, Structable, Valuable, Value, Visit};
#[cfg(feature = "nus")]
use sachet::{common::CafeContentFileInformation, title::TitleID};
#[derive(Clone, Debug, PartialEq, Eq, Valuable)]
pub enum ResolvedLocation {
Filesystem(FilesystemLocation),
Network(()),
#[cfg_attr(docsrs, doc(cfg(feature = "nus")))]
#[cfg(feature = "nus")]
NUSLocation(TitleID, PathBuf, PathBuf),
}
#[derive(Clone, Debug, PartialEq, Eq, Valuable)]
pub enum ItemInFolder {
Local(PathBuf, usize),
#[cfg(feature = "nus")]
Nus(
Option<TitleID>,
PathBuf,
PathBuf,
Option<CafeContentFileInformation>,
),
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct FilesystemLocation {
resolved_path: PathBuf,
closest_resolved_path: PathBuf,
canonicalized_is_exact: bool,
}
impl FilesystemLocation {
#[must_use]
pub const fn new(
resolved_path: PathBuf,
closest_resolved_path: PathBuf,
canonicalized_is_exact: bool,
) -> Self {
Self {
resolved_path,
closest_resolved_path,
canonicalized_is_exact,
}
}
#[must_use]
pub const fn resolved_path(&self) -> &PathBuf {
&self.resolved_path
}
#[must_use]
pub const fn closest_resolved_path(&self) -> &PathBuf {
&self.closest_resolved_path
}
#[must_use]
pub const fn canonicalized_is_exact(&self) -> bool {
self.canonicalized_is_exact
}
}
const FILESYSTEM_LOCATION_FIELDS: &[NamedField<'static>] = &[
NamedField::new("resolved_path"),
NamedField::new("closest_resolved_path"),
NamedField::new("canonicalized_is_exact"),
];
impl Structable for FilesystemLocation {
fn definition(&self) -> StructDef<'_> {
StructDef::new_static(
"FilesystemLocation",
Fields::Named(FILESYSTEM_LOCATION_FIELDS),
)
}
}
impl Valuable for FilesystemLocation {
fn as_value(&self) -> Value<'_> {
Value::Structable(self)
}
fn visit(&self, visitor: &mut dyn Visit) {
visitor.visit_named_fields(&NamedValues::new(
FILESYSTEM_LOCATION_FIELDS,
&[
Valuable::as_value(&self.resolved_path),
Valuable::as_value(&self.closest_resolved_path),
Valuable::as_value(&self.canonicalized_is_exact),
],
));
}
}