From e1df098c885bda5cd0b375cb46c460367abe4f17 Mon Sep 17 00:00:00 2001 From: diogo464 Date: Fri, 9 Jul 2021 04:14:02 -0400 Subject: Renamed LinkDesc to LinkCreateParams --- dotup/src/depot.rs | 14 +++++++------- dotup/src/lib.rs | 4 +++- dotup_cli/src/commands/link.rs | 2 +- dotup_cli/src/main.rs | 2 +- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/dotup/src/depot.rs b/dotup/src/depot.rs index 0930835..227d824 100644 --- a/dotup/src/depot.rs +++ b/dotup/src/depot.rs @@ -47,13 +47,13 @@ pub struct DepotConfig { slotmap::new_key_type! { pub struct LinkID; } #[derive(Debug)] -pub struct LinkDesc { +pub struct LinkCreateParams { pub origin: PathBuf, /// This must be a relative path pub destination: PathBuf, } -impl LinkDesc { +impl LinkCreateParams { pub fn new(origin: impl Into, destination: impl Into) -> Self { Self { origin: origin.into(), @@ -62,7 +62,7 @@ impl LinkDesc { } } -impl std::fmt::Display for LinkDesc { +impl std::fmt::Display for LinkCreateParams { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!( f, @@ -73,7 +73,7 @@ impl std::fmt::Display for LinkDesc { } } -impl From for LinkDesc { +impl From for LinkCreateParams { fn from(archive_link: ArchiveLink) -> Self { Self { origin: archive_link.origin, @@ -158,7 +158,7 @@ impl Depot { /// Creates a new link from the description. /// The origin path must exist. - pub fn create_link(&mut self, link_desc: LinkDesc) -> Result { + pub fn create_link(&mut self, link_desc: LinkCreateParams) -> Result { let link = depot_create_link(self, link_desc)?; let link_id = depot_insert_link(self, link); Ok(link_id) @@ -227,7 +227,7 @@ fn depot_create(config: DepotConfig) -> Result { }; for archive_link in config.archive.links { - let link_desc = LinkDesc::from(archive_link); + let link_desc = LinkCreateParams::from(archive_link); let link = depot_create_link(&depot, link_desc)?; depot_insert_link(&mut depot, link); } @@ -248,7 +248,7 @@ fn depot_archive(depot: &Depot) -> Archive { /// Create a valid link for that given Depot using the given link desc. /// The link id is corrected when the link is inserted in the depot. -fn depot_create_link(depot: &Depot, link_desc: LinkDesc) -> Result { +fn depot_create_link(depot: &Depot, link_desc: LinkCreateParams) -> Result { // link_ensure_relative_path(&link_desc.origin)?; link_ensure_relative_path(&link_desc.destination)?; debug_assert!(utils::is_canonical(&depot.base_path())?); diff --git a/dotup/src/lib.rs b/dotup/src/lib.rs index 49639ce..96c4cd7 100644 --- a/dotup/src/lib.rs +++ b/dotup/src/lib.rs @@ -8,7 +8,9 @@ pub use archive::{ archive_deserialize, archive_exists, archive_read, archive_serialize, archive_write, Archive, ArchiveLink, }; -pub use depot::{Depot, DepotConfig, Link, LinkCreateError, LinkDesc, LinkID, LinkInstallError}; +pub use depot::{ + Depot, DepotConfig, Link, LinkCreateError, LinkCreateParams, LinkID, LinkInstallError, +}; pub use error::{Error, Result}; pub(crate) mod internal_prelude { diff --git a/dotup_cli/src/commands/link.rs b/dotup_cli/src/commands/link.rs index 87453bd..bed3744 100644 --- a/dotup_cli/src/commands/link.rs +++ b/dotup_cli/src/commands/link.rs @@ -25,7 +25,7 @@ pub fn main(config: Config, opts: Opts) -> anyhow::Result<()> { if let Some(destination) = destination { for path in collect_file_type(origins, FileType::File)? { - let link_desc = LinkDesc { + let link_desc = LinkCreateParams { origin: path, destination: destination.clone(), }; diff --git a/dotup_cli/src/main.rs b/dotup_cli/src/main.rs index 6d020e1..8830853 100644 --- a/dotup_cli/src/main.rs +++ b/dotup_cli/src/main.rs @@ -7,7 +7,7 @@ pub use config::Config; pub mod prelude { pub use super::Config; - pub use dotup::{Archive, Depot, DepotConfig, Link, LinkDesc, LinkID}; + pub use dotup::{Archive, Depot, DepotConfig, Link, LinkCreateParams, LinkID}; } use clap::{AppSettings, Clap}; -- cgit