macro_rules! unit_stub {
($(#[$meta:meta])* $name:ident, $kind:expr) => {
$(#[$meta])*
#[derive(Debug, Default, Clone)]
pub struct $name {
_priv: (),
}
impl $name {
#[must_use]
pub fn new() -> Self {
Self { _priv: () }
}
}
impl $crate::source::Source for $name {
fn kind(&self) -> $crate::source::SourceKind {
$kind
}
fn probe(&self) -> Result<Option<$crate::source::Probe>, $crate::error::Error> {
Ok(None)
}
}
};
}
macro_rules! path_stub {
($(#[$meta:meta])* $name:ident, $kind:expr, $default:expr) => {
$(#[$meta])*
#[derive(Debug, Clone)]
pub struct $name {
path: std::path::PathBuf,
}
impl $name {
#[doc = concat!("Construct with the standard default path (`", $default, "`).")]
#[must_use]
pub fn new() -> Self {
Self { path: std::path::PathBuf::from($default) }
}
#[must_use]
pub fn at(path: impl Into<std::path::PathBuf>) -> Self {
Self { path: path.into() }
}
#[must_use]
pub fn path(&self) -> &std::path::Path {
&self.path
}
}
impl Default for $name {
fn default() -> Self {
Self::new()
}
}
impl $crate::source::Source for $name {
fn kind(&self) -> $crate::source::SourceKind {
$kind
}
fn probe(&self) -> Result<Option<$crate::source::Probe>, $crate::error::Error> {
Ok(None)
}
}
};
}
pub(crate) use path_stub;
pub(crate) use unit_stub;