aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordiogo464 <[email protected]>2021-07-09 04:14:02 -0400
committerdiogo464 <[email protected]>2021-07-09 04:14:02 -0400
commite1df098c885bda5cd0b375cb46c460367abe4f17 (patch)
tree348ddce946295c02870ad47d094d5d755cbe2e7b
parent862fed11b358cf0d8747decb0c343cfe94784bad (diff)
Renamed LinkDesc to LinkCreateParams
-rw-r--r--dotup/src/depot.rs14
-rw-r--r--dotup/src/lib.rs4
-rw-r--r--dotup_cli/src/commands/link.rs2
-rw-r--r--dotup_cli/src/main.rs2
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 {
47slotmap::new_key_type! { pub struct LinkID; } 47slotmap::new_key_type! { pub struct LinkID; }
48 48
49#[derive(Debug)] 49#[derive(Debug)]
50pub struct LinkDesc { 50pub struct LinkCreateParams {
51 pub origin: PathBuf, 51 pub origin: PathBuf,
52 /// This must be a relative path 52 /// This must be a relative path
53 pub destination: PathBuf, 53 pub destination: PathBuf,
54} 54}
55 55
56impl LinkDesc { 56impl LinkCreateParams {
57 pub fn new(origin: impl Into<PathBuf>, destination: impl Into<PathBuf>) -> Self { 57 pub fn new(origin: impl Into<PathBuf>, destination: impl Into<PathBuf>) -> Self {
58 Self { 58 Self {
59 origin: origin.into(), 59 origin: origin.into(),
@@ -62,7 +62,7 @@ impl LinkDesc {
62 } 62 }
63} 63}
64 64
65impl std::fmt::Display for LinkDesc { 65impl std::fmt::Display for LinkCreateParams {
66 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 66 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
67 write!( 67 write!(
68 f, 68 f,
@@ -73,7 +73,7 @@ impl std::fmt::Display for LinkDesc {
73 } 73 }
74} 74}
75 75
76impl From<ArchiveLink> for LinkDesc { 76impl From<ArchiveLink> for LinkCreateParams {
77 fn from(archive_link: ArchiveLink) -> Self { 77 fn from(archive_link: ArchiveLink) -> Self {
78 Self { 78 Self {
79 origin: archive_link.origin, 79 origin: archive_link.origin,
@@ -158,7 +158,7 @@ impl Depot {
158 158
159 /// Creates a new link from the description. 159 /// Creates a new link from the description.
160 /// The origin path must exist. 160 /// The origin path must exist.
161 pub fn create_link(&mut self, link_desc: LinkDesc) -> Result<LinkID, LinkCreateError> { 161 pub fn create_link(&mut self, link_desc: LinkCreateParams) -> Result<LinkID, LinkCreateError> {
162 let link = depot_create_link(self, link_desc)?; 162 let link = depot_create_link(self, link_desc)?;
163 let link_id = depot_insert_link(self, link); 163 let link_id = depot_insert_link(self, link);
164 Ok(link_id) 164 Ok(link_id)
@@ -227,7 +227,7 @@ fn depot_create(config: DepotConfig) -> Result<Depot> {
227 }; 227 };
228 228
229 for archive_link in config.archive.links { 229 for archive_link in config.archive.links {
230 let link_desc = LinkDesc::from(archive_link); 230 let link_desc = LinkCreateParams::from(archive_link);
231 let link = depot_create_link(&depot, link_desc)?; 231 let link = depot_create_link(&depot, link_desc)?;
232 depot_insert_link(&mut depot, link); 232 depot_insert_link(&mut depot, link);
233 } 233 }
@@ -248,7 +248,7 @@ fn depot_archive(depot: &Depot) -> Archive {
248 248
249/// Create a valid link for that given Depot using the given link desc. 249/// Create a valid link for that given Depot using the given link desc.
250/// The link id is corrected when the link is inserted in the depot. 250/// The link id is corrected when the link is inserted in the depot.
251fn depot_create_link(depot: &Depot, link_desc: LinkDesc) -> Result<Link, LinkCreateError> { 251fn depot_create_link(depot: &Depot, link_desc: LinkCreateParams) -> Result<Link, LinkCreateError> {
252 // link_ensure_relative_path(&link_desc.origin)?; 252 // link_ensure_relative_path(&link_desc.origin)?;
253 link_ensure_relative_path(&link_desc.destination)?; 253 link_ensure_relative_path(&link_desc.destination)?;
254 debug_assert!(utils::is_canonical(&depot.base_path())?); 254 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::{
8 archive_deserialize, archive_exists, archive_read, archive_serialize, archive_write, Archive, 8 archive_deserialize, archive_exists, archive_read, archive_serialize, archive_write, Archive,
9 ArchiveLink, 9 ArchiveLink,
10}; 10};
11pub use depot::{Depot, DepotConfig, Link, LinkCreateError, LinkDesc, LinkID, LinkInstallError}; 11pub use depot::{
12 Depot, DepotConfig, Link, LinkCreateError, LinkCreateParams, LinkID, LinkInstallError,
13};
12pub use error::{Error, Result}; 14pub use error::{Error, Result};
13 15
14pub(crate) mod internal_prelude { 16pub(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<()> {
25 25
26 if let Some(destination) = destination { 26 if let Some(destination) = destination {
27 for path in collect_file_type(origins, FileType::File)? { 27 for path in collect_file_type(origins, FileType::File)? {
28 let link_desc = LinkDesc { 28 let link_desc = LinkCreateParams {
29 origin: path, 29 origin: path,
30 destination: destination.clone(), 30 destination: destination.clone(),
31 }; 31 };
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;
7 7
8pub mod prelude { 8pub mod prelude {
9 pub use super::Config; 9 pub use super::Config;
10 pub use dotup::{Archive, Depot, DepotConfig, Link, LinkDesc, LinkID}; 10 pub use dotup::{Archive, Depot, DepotConfig, Link, LinkCreateParams, LinkID};
11} 11}
12 12
13use clap::{AppSettings, Clap}; 13use clap::{AppSettings, Clap};