Skip to content

Commit 8899158

Browse files
committed
fmt: cargo fmt
1 parent 0303aca commit 8899158

File tree

3 files changed

+29
-36
lines changed

3 files changed

+29
-36
lines changed

src/data.rs

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ use clap::Parser;
77
use linked_hash_set::LinkedHashSet;
88
use merge::Merge;
99
use rnix::{types::*, SyntaxKind::*};
10-
use thiserror::Error;
1110
use std::net::{SocketAddr, ToSocketAddrs};
11+
use thiserror::Error;
1212

1313
use crate::settings;
1414

@@ -73,11 +73,7 @@ impl<'a> Target {
7373
}
7474
};
7575
Ok({
76-
let hostname_: Option<String> = if ip.is_some() {
77-
ip
78-
} else {
79-
hostname
80-
};
76+
let hostname_: Option<String> = if ip.is_some() { ip } else { hostname };
8177
let d = DeployData::new(
8278
repo,
8379
node.to_owned(),
@@ -182,7 +178,6 @@ impl std::str::FromStr for Target {
182178
};
183179
};
184180

185-
186181
let mut node: Option<String> = None;
187182
let mut profile: Option<String> = None;
188183

@@ -197,7 +192,7 @@ impl std::str::FromStr for Target {
197192
node: None,
198193
profile: None,
199194
ip, // NB: error if not none; catched on target resolve
200-
})
195+
});
201196
}
202197
};
203198

@@ -291,9 +286,7 @@ fn test_deploy_target_from_str() {
291286
);
292287

293288
assert_eq!(
294-
"../examples/system#example"
295-
.parse::<Target>()
296-
.unwrap(),
289+
"../examples/system#example".parse::<Target>().unwrap(),
297290
Target {
298291
repo: "../examples/system".to_string(),
299292
node: Some("example".to_string()),
@@ -340,7 +333,6 @@ pub struct DeployData<'a> {
340333
// over potentially a series of sockets to deploy
341334
// to
342335
// pub sockets: Vec<SocketAddr>,
343-
344336
pub ssh_user: String,
345337
pub ssh_uri: String,
346338
pub temp_path: String,
@@ -450,18 +442,24 @@ impl<'a> DeployData<'a> {
450442
};
451443
let hostname = match hostname {
452444
Some(x) => x,
453-
None => if let Some(x) = &node.node_settings.hostname {
454-
x.to_string()
455-
} else {
456-
return Err(DeployDataError::NoHost(node_name));
457-
},
445+
None => {
446+
if let Some(x) = &node.node_settings.hostname {
447+
x.to_string()
448+
} else {
449+
return Err(DeployDataError::NoHost(node_name));
450+
}
451+
}
458452
};
459453
let maybe_iter = &mut hostname[..].to_socket_addrs();
460454
let sockets: Vec<SocketAddr> = match maybe_iter {
461455
Ok(x) => x.into_iter().collect(),
462-
Err(err) => return Err(
463-
DeployDataError::InvalidSockent(repo, hostname, err.to_string()),
464-
),
456+
Err(err) => {
457+
return Err(DeployDataError::InvalidSockent(
458+
repo,
459+
hostname,
460+
err.to_string(),
461+
))
462+
}
465463
};
466464
let ssh_uri = format!("ssh://{}@{}", &ssh_user, sockets.first().unwrap());
467465

src/deploy.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ pub struct SshCommand<'a> {
1818
impl<'a> SshCommand<'a> {
1919
pub fn from_data(d: &'a data::DeployData) -> Result<Self, data::DeployDataError> {
2020
let opts = d.merged_settings.ssh_opts.as_ref();
21-
Ok(SshCommand { ssh_uri: d.ssh_uri.as_ref(), opts })
21+
Ok(SshCommand {
22+
ssh_uri: d.ssh_uri.as_ref(),
23+
opts,
24+
})
2225
}
2326

2427
fn build(&self) -> Command {
@@ -299,7 +302,6 @@ pub async fn confirm_profile(
299302
ssh: SshCommand<'_>,
300303
confirm: ConfirmCommand<'_>,
301304
) -> Result<(), ConfirmProfileError> {
302-
303305
debug!("Entering confirm_profile function ...");
304306

305307
let mut ssh_confirm_cmd = ssh.build();
@@ -349,7 +351,6 @@ pub async fn deploy_profile(
349351
wait: WaitCommand<'_>,
350352
confirm: ConfirmCommand<'_>,
351353
) -> Result<(), DeployProfileError> {
352-
353354
debug!("Entering deploy_profile function ...");
354355

355356
if !activate.dry_activate {
@@ -383,7 +384,6 @@ pub async fn deploy_profile(
383384
info!("Success activating, done!");
384385
}
385386
} else {
386-
387387
let ssh_activate = ssh_activate_cmd
388388
.arg(activate_cmd)
389389
.spawn()
@@ -457,7 +457,6 @@ pub async fn revoke(
457457
ssh: SshCommand<'_>,
458458
revoke: RevokeCommand<'_>,
459459
) -> Result<(), RevokeProfileError> {
460-
461460
debug!("Entering revoke function ...");
462461

463462
info!(

src/push.rs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,12 @@ impl<'a> CopyCommand<'a> {
113113
fast_connection: d.merged_settings.fast_connection,
114114
check_sigs: &d.flags.checksigs,
115115
hostname: uri,
116-
nix_ssh_opts: format!("{} -p {}",
117-
d
118-
.merged_settings
119-
.ssh_opts
120-
.iter()
121-
.fold("".to_string(), |s, o| format!("{} {}", s, o)),
116+
nix_ssh_opts: format!(
117+
"{} -p {}",
118+
d.merged_settings
119+
.ssh_opts
120+
.iter()
121+
.fold("".to_string(), |s, o| format!("{} {}", s, o)),
122122
port,
123123
),
124124
}
@@ -203,7 +203,6 @@ pub async fn push_profile(
203203
sign: SignCommand<'_>,
204204
copy: CopyCommand<'_>,
205205
) -> Result<(), PushProfileError> {
206-
207206
debug!("Entering push_profil function ...");
208207

209208
let node_name = build.node_name;
@@ -240,10 +239,7 @@ pub async fn push_profile(
240239

241240
let mut build_cmd = build.build(*derivation_name, supports_flakes);
242241

243-
let build_cmd_handle = build_cmd
244-
.output()
245-
.await
246-
.map_err(PushProfileError::Build)?;
242+
let build_cmd_handle = build_cmd.output().await.map_err(PushProfileError::Build)?;
247243

248244
match build_cmd_handle.status.code() {
249245
Some(0) => (),

0 commit comments

Comments
 (0)