use crate::commands::{StowData, StowOptions, UnstowData};
use std::path::PathBuf;
use tracing::instrument;
#[derive(Debug, Clone)]
pub struct RestowData {
pub(crate) unstow_data: UnstowData,
pub(crate) stow_data: StowData,
}
impl From<RestowData> for UnstowData {
fn from(restow_data: RestowData) -> Self {
restow_data.unstow_data
}
}
impl From<RestowData> for StowData {
fn from(restow_data: RestowData) -> Self {
restow_data.stow_data
}
}
impl AsRef<UnstowData> for RestowData {
fn as_ref(&self) -> &UnstowData {
&self.unstow_data
}
}
impl AsRef<StowData> for RestowData {
fn as_ref(&self) -> &StowData {
&self.stow_data
}
}
impl RestowData {
#[must_use]
#[instrument(level = "trace")]
pub fn new(target: PathBuf, directory: PathBuf, options: StowOptions) -> Self {
Self {
unstow_data: UnstowData::new(
target.clone(),
directory.clone(),
options.dot_file_prefix.clone(),
),
stow_data: StowData::new(target, directory, options),
}
}
}