mod caps;
mod error;
mod inspect;
mod journal;
mod overlay;
mod path;
mod plan;
mod progress;
mod recover;
mod state;
mod sys;
mod transaction;
pub mod vfs;
#[cfg(feature = "sim")]
pub mod sim;
use std::path::Path;
pub use caps::Caps;
pub use error::{Error, Result};
pub use inspect::{Inspection, RecoveryAction, TokenInspection, TokenPosition, TxInspection};
pub use path::RelPath;
pub use recover::RecoveryReport;
pub use transaction::{Options, Transaction};
pub fn recover(root: impl AsRef<Path>) -> Result<RecoveryReport> {
recover_with(root, &Options::default())
}
pub fn recover_with(root: impl AsRef<Path>, opts: &Options) -> Result<RecoveryReport> {
#[cfg(target_os = "linux")]
{
recover_on(&sys::linux::LinuxFs::open(root.as_ref())?, opts)
}
#[cfg(not(target_os = "linux"))]
{
let _ = (root, opts);
Err(Error::UnsupportedPlatform)
}
}
pub fn recover_on(vfs: &dyn vfs::Vfs, opts: &Options) -> Result<RecoveryReport> {
if vfs.stat(&state::private_dir())?.is_none() {
return Ok(RecoveryReport::default());
}
let _lock = vfs.lock(true)?;
caps::probe(vfs, opts.allow_untested())?;
recover::recover_locked(vfs)
}
pub fn inspect(root: impl AsRef<Path>) -> Result<Inspection> {
#[cfg(target_os = "linux")]
{
inspect_on(&sys::linux::LinuxFs::open(root.as_ref())?)
}
#[cfg(not(target_os = "linux"))]
{
let _ = root;
Err(Error::UnsupportedPlatform)
}
}
pub fn inspect_on(vfs: &dyn vfs::Vfs) -> Result<Inspection> {
inspect::inspect_on(vfs)
}