Skip to content

Commit 4ef9e65

Browse files
committed
style: Lint
1 parent c615d05 commit 4ef9e65

File tree

5 files changed

+44
-47
lines changed

5 files changed

+44
-47
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<p align="center">~ Remotefs SSH client ~</p>
1212

1313
<p align="center">Developed by <a href="https://veeso.github.io/" target="_blank">@veeso</a></p>
14-
<p align="center">Current version: 0.6.2 (16/05/2025)</p>
14+
<p align="center">Current version: 0.6.3 (21/07/2025)</p>
1515

1616
<p align="center">
1717
<a href="https://opensource.org/licenses/MIT"

src/ssh/commons.rs

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ pub fn connect(opts: &SshOpts) -> RemoteResult<Session> {
4949
ssh_config.connection_timeout.as_secs()
5050
);
5151
if let Ok(tcp_stream) = tcp_connect(socket_addr, ssh_config.connection_timeout) {
52-
debug!("Connection established with address {}", socket_addr);
52+
debug!("Connection established with address {socket_addr}");
5353
stream = Some(tcp_stream);
5454
break;
5555
}
@@ -74,7 +74,7 @@ pub fn connect(opts: &SshOpts) -> RemoteResult<Session> {
7474
let mut session = match Session::new() {
7575
Ok(s) => s,
7676
Err(err) => {
77-
error!("Could not create session: {}", err);
77+
error!("Could not create session: {err}");
7878
return Err(RemoteError::new_ex(RemoteErrorType::ConnectionError, err));
7979
}
8080
};
@@ -84,7 +84,7 @@ pub fn connect(opts: &SshOpts) -> RemoteResult<Session> {
8484
set_algo_prefs(&mut session, opts, &ssh_config)?;
8585
// Open connection and initialize handshake
8686
if let Err(err) = session.handshake() {
87-
error!("SSH handshake failed: {}", err);
87+
error!("SSH handshake failed: {err}");
8888
return Err(RemoteError::new_ex(RemoteErrorType::ProtocolError, err));
8989
}
9090

@@ -96,7 +96,7 @@ pub fn connect(opts: &SshOpts) -> RemoteResult<Session> {
9696
return Ok(session);
9797
}
9898
Err(err) => {
99-
error!("Could not authenticate with ssh agent: {}", err);
99+
error!("Could not authenticate with ssh agent: {err}");
100100
}
101101
}
102102
}
@@ -162,47 +162,47 @@ fn set_algo_prefs(session: &mut Session, opts: &SshOpts, config: &Config) -> Rem
162162
let params = &config.params;
163163
trace!("Configuring algorithm preferences...");
164164
if let Some(compress) = params.compression {
165-
trace!("compression: {}", compress);
165+
trace!("compression: {compress}");
166166
session.set_compress(compress);
167167
}
168168

169169
// kex
170170
let algos = params.kex_algorithms.algorithms().join(",");
171-
trace!("Configuring KEX algorithms: {}", algos);
171+
trace!("Configuring KEX algorithms: {algos}");
172172
if let Err(err) = session.method_pref(SshMethodType::Kex, algos.as_str()) {
173-
error!("Could not set KEX algorithms: {}", err);
173+
error!("Could not set KEX algorithms: {err}");
174174
return Err(RemoteError::new_ex(RemoteErrorType::ProtocolError, err));
175175
}
176176

177177
// HostKey
178178
let algos = params.host_key_algorithms.algorithms().join(",");
179-
trace!("Configuring HostKey algorithms: {}", algos);
179+
trace!("Configuring HostKey algorithms: {algos}");
180180
if let Err(err) = session.method_pref(SshMethodType::HostKey, algos.as_str()) {
181-
error!("Could not set host key algorithms: {}", err);
181+
error!("Could not set host key algorithms: {err}");
182182
return Err(RemoteError::new_ex(RemoteErrorType::ProtocolError, err));
183183
}
184184

185185
// ciphers
186186
let algos = params.ciphers.algorithms().join(",");
187-
trace!("Configuring Crypt algorithms: {}", algos);
187+
trace!("Configuring Crypt algorithms: {algos}");
188188
if let Err(err) = session.method_pref(SshMethodType::CryptCs, algos.as_str()) {
189-
error!("Could not set crypt algorithms (client-server): {}", err);
189+
error!("Could not set crypt algorithms (client-server): {err}");
190190
return Err(RemoteError::new_ex(RemoteErrorType::ProtocolError, err));
191191
}
192192
if let Err(err) = session.method_pref(SshMethodType::CryptSc, algos.as_str()) {
193-
error!("Could not set crypt algorithms (server-client): {}", err);
193+
error!("Could not set crypt algorithms (server-client): {err}");
194194
return Err(RemoteError::new_ex(RemoteErrorType::ProtocolError, err));
195195
}
196196

197197
// MAC
198198
let algos = params.mac.algorithms().join(",");
199-
trace!("Configuring MAC algorithms: {}", algos);
199+
trace!("Configuring MAC algorithms: {algos}");
200200
if let Err(err) = session.method_pref(SshMethodType::MacCs, algos.as_str()) {
201-
error!("Could not set MAC algorithms (client-server): {}", err);
201+
error!("Could not set MAC algorithms (client-server): {err}");
202202
return Err(RemoteError::new_ex(RemoteErrorType::ProtocolError, err));
203203
}
204204
if let Err(err) = session.method_pref(SshMethodType::MacSc, algos.as_str()) {
205-
error!("Could not set MAC algorithms (server-client): {}", err);
205+
error!("Could not set MAC algorithms (server-client): {err}");
206206
return Err(RemoteError::new_ex(RemoteErrorType::ProtocolError, err));
207207
}
208208

@@ -278,7 +278,7 @@ fn session_auth_with_rsakey(
278278
password: Option<&str>,
279279
identity_file: Option<&[PathBuf]>,
280280
) -> RemoteResult<()> {
281-
debug!("Authenticating with username '{}' and RSA key", username);
281+
debug!("Authenticating with username '{username}' and RSA key");
282282
let mut keys = vec![private_key];
283283
if let Some(identity_file) = identity_file {
284284
let other_keys: Vec<&Path> = identity_file.iter().map(|x| x.as_path()).collect();
@@ -293,7 +293,7 @@ fn session_auth_with_rsakey(
293293
return Ok(());
294294
}
295295
Err(err) => {
296-
error!("Authentication failed: {}", err);
296+
error!("Authentication failed: {err}");
297297
}
298298
}
299299
}
@@ -331,9 +331,9 @@ fn session_auth_with_password(
331331
password: &str,
332332
) -> RemoteResult<()> {
333333
// Username / password
334-
debug!("Authenticating with username '{}' and password", username);
334+
debug!("Authenticating with username '{username}' and password");
335335
if let Err(err) = session.userauth_password(username, password) {
336-
error!("Authentication failed: {}", err);
336+
error!("Authentication failed: {err}");
337337
Err(RemoteError::new_ex(
338338
RemoteErrorType::AuthenticationFailed,
339339
err,
@@ -371,7 +371,7 @@ pub fn perform_shell_cmd<S: AsRef<str>>(session: &mut Session, cmd: S) -> Remote
371371
Ok(_) => {
372372
// Wait close
373373
let _ = channel.wait_close();
374-
trace!("Command output: {}", output);
374+
trace!("Command output: {output}");
375375
Ok(output)
376376
}
377377
Err(err) => Err(RemoteError::new_ex(
@@ -397,9 +397,9 @@ pub fn perform_shell_cmd_with_rc<S: AsRef<str>>(
397397
) -> RemoteResult<(u32, String)> {
398398
let output = perform_shell_cmd(session, format!("{}; echo $?", cmd.as_ref()))?;
399399
if let Some(index) = output.trim().rfind('\n') {
400-
trace!("Read from stdout: '{}'", output);
400+
trace!("Read from stdout: '{output}'");
401401
let actual_output = (output[0..index + 1]).to_string();
402-
trace!("Actual output '{}'", actual_output);
402+
trace!("Actual output '{actual_output}'");
403403
trace!("Parsing return code '{}'", output[index..].trim());
404404
let rc = match u32::from_str(output[index..].trim()).ok() {
405405
Some(val) => val,
@@ -410,7 +410,7 @@ pub fn perform_shell_cmd_with_rc<S: AsRef<str>>(
410410
));
411411
}
412412
};
413-
debug!(r#"Command output: "{}"; exit code: {}"#, actual_output, rc);
413+
debug!(r#"Command output: "{actual_output}"; exit code: {rc}"#);
414414
Ok((rc, actual_output))
415415
} else {
416416
match u32::from_str(output.trim()).ok() {
@@ -446,7 +446,7 @@ mod test {
446446
.password("password");
447447

448448
if let Err(err) = connect(&opts) {
449-
panic!("Could not connect to server: {}", err);
449+
panic!("Could not connect to server: {err}");
450450
}
451451
let session = connect(&opts).unwrap();
452452
assert!(session.authenticated());

src/ssh/container.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ pub struct OpensshServer {
5050
impl OpensshServer {
5151
pub fn start() -> Self {
5252
use testcontainers::runners::SyncRunner;
53-
let container = OpensshServerImage::default()
53+
let container = OpensshServerImage
5454
.start()
5555
.expect("Failed to start container");
5656

src/ssh/scp.rs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ impl ScpFs {
6060
/// Parse a line of `ls -l` output and tokenize the output into a `FsFile`
6161
fn parse_ls_output(&self, path: &Path, line: &str) -> Result<File, ()> {
6262
// Prepare list regex
63-
trace!("Parsing LS line: '{}'", line);
63+
trace!("Parsing LS line: '{line}'");
6464
// Apply regex to result
6565
match LS_RE.captures(line) {
6666
// String matches regex
@@ -554,7 +554,7 @@ impl RemoteFs for ScpFs {
554554

555555
fn exec(&mut self, cmd: &str) -> RemoteResult<(u32, String)> {
556556
self.check_connection()?;
557-
debug!(r#"Executing command "{}""#, cmd);
557+
debug!(r#"Executing command "{cmd}""#);
558558
commons::perform_shell_cmd_at_with_rc(
559559
self.session.as_mut().unwrap(),
560560
cmd,
@@ -588,10 +588,7 @@ impl RemoteFs for ScpFs {
588588
.ok()
589589
.unwrap_or(Duration::ZERO)
590590
.as_secs();
591-
trace!(
592-
"Creating file with mode {:o}, accessed: {}, modified: {}",
593-
mode, accessed, modified
594-
);
591+
trace!("Creating file with mode {mode:o}, accessed: {accessed}, modified: {modified}");
595592
match self.session.as_mut().unwrap().scp_send(
596593
path.as_path(),
597594
mode,
@@ -600,7 +597,7 @@ impl RemoteFs for ScpFs {
600597
) {
601598
Ok(channel) => Ok(WriteStream::from(Box::new(channel) as Box<dyn Write + Send>)),
602599
Err(err) => {
603-
error!("Failed to create file: {}", err);
600+
error!("Failed to create file: {err}");
604601
Err(RemoteError::new_ex(RemoteErrorType::FileCreateDenied, err))
605602
}
606603
}
@@ -619,7 +616,7 @@ impl RemoteFs for ScpFs {
619616
match self.session.as_mut().unwrap().scp_recv(path.as_path()) {
620617
Ok((channel, _)) => Ok(ReadStream::from(Box::new(channel) as Box<dyn Read + Send>)),
621618
Err(err) => {
622-
error!("Failed to open file: {}", err);
619+
error!("Failed to open file: {err}");
623620
Err(RemoteError::new_ex(RemoteErrorType::CouldNotOpenFile, err))
624621
}
625622
}
@@ -924,7 +921,7 @@ mod test {
924921
.list_dir(wrkdir.as_path())
925922
.ok()
926923
.unwrap()
927-
.get(0)
924+
.first()
928925
.unwrap()
929926
.clone();
930927
assert_eq!(file.name().as_str(), "a.txt");
@@ -1597,6 +1594,6 @@ mod test {
15971594
.map(char::from)
15981595
.take(8)
15991596
.collect();
1600-
format!("/tmp/temp_{}", name)
1597+
format!("/tmp/temp_{name}")
16011598
}
16021599
}

src/ssh/sftp.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ impl SftpFs {
6464
None => "/".to_string(),
6565
Some(name) => name.to_string_lossy().to_string(),
6666
};
67-
debug!("Found file {}", name);
67+
debug!("Found file {name}");
6868
// parse metadata
6969
let uid = metadata.uid;
7070
let gid = metadata.gid;
@@ -150,7 +150,7 @@ impl RemoteFs for SftpFs {
150150
let sftp = match session.sftp() {
151151
Ok(s) => s,
152152
Err(err) => {
153-
error!("Could not get sftp client: {}", err);
153+
error!("Could not get sftp client: {err}");
154154
return Err(RemoteError::new_ex(RemoteErrorType::ProtocolError, err));
155155
}
156156
};
@@ -242,7 +242,7 @@ impl RemoteFs for SftpFs {
242242
sftp.stat(path.as_path())
243243
.map(|x| self.make_fsentry(path.as_path(), &x))
244244
.map_err(|e| {
245-
error!("Stat failed: {}", e);
245+
error!("Stat failed: {e}");
246246
RemoteError::new_ex(RemoteErrorType::NoSuchFileOrDirectory, e)
247247
})
248248
} else {
@@ -257,7 +257,7 @@ impl RemoteFs for SftpFs {
257257
sftp.setstat(path.as_path(), Self::metadata_to_filestat(metadata))
258258
.map(|_| ())
259259
.map_err(|e| {
260-
error!("Setstat failed: {}", e);
260+
error!("Setstat failed: {e}");
261261
RemoteError::new_ex(RemoteErrorType::StatFailed, e)
262262
})
263263
} else {
@@ -281,7 +281,7 @@ impl RemoteFs for SftpFs {
281281
let path = path_utils::absolutize(self.wrkdir.as_path(), path);
282282
debug!("Remove file {}", path.display());
283283
sftp.unlink(path.as_path()).map_err(|e| {
284-
error!("Remove failed: {}", e);
284+
error!("Remove failed: {e}");
285285
RemoteError::new_ex(RemoteErrorType::CouldNotRemoveFile, e)
286286
})
287287
} else {
@@ -294,7 +294,7 @@ impl RemoteFs for SftpFs {
294294
let path = path_utils::absolutize(self.wrkdir.as_path(), path);
295295
debug!("Remove dir {}", path.display());
296296
sftp.rmdir(path.as_path()).map_err(|e| {
297-
error!("Remove failed: {}", e);
297+
error!("Remove failed: {e}");
298298
RemoteError::new_ex(RemoteErrorType::CouldNotRemoveFile, e)
299299
})
300300
} else {
@@ -320,7 +320,7 @@ impl RemoteFs for SftpFs {
320320
.unwrap()
321321
.mkdir(path.as_path(), u32::from(mode) as i32)
322322
.map_err(|e| {
323-
error!("Create dir failed: {}", e);
323+
error!("Create dir failed: {e}");
324324
RemoteError::new_ex(RemoteErrorType::FileCreateDenied, e)
325325
})
326326
}
@@ -343,7 +343,7 @@ impl RemoteFs for SftpFs {
343343
.unwrap()
344344
.symlink(target, path.as_path())
345345
.map_err(|e| {
346-
error!("Symlink failed: {}", e);
346+
error!("Symlink failed: {e}");
347347
RemoteError::new_ex(RemoteErrorType::FileCreateDenied, e)
348348
})
349349
}
@@ -393,7 +393,7 @@ impl RemoteFs for SftpFs {
393393

394394
fn exec(&mut self, cmd: &str) -> RemoteResult<(u32, String)> {
395395
self.check_connection()?;
396-
debug!(r#"Executing command "{}""#, cmd);
396+
debug!(r#"Executing command "{cmd}""#);
397397
commons::perform_shell_cmd_at_with_rc(
398398
self.session.as_mut().unwrap(),
399399
cmd,
@@ -875,7 +875,7 @@ mod test {
875875
.list_dir(wrkdir.as_path())
876876
.ok()
877877
.unwrap()
878-
.get(0)
878+
.first()
879879
.unwrap()
880880
.clone();
881881
assert_eq!(file.name().as_str(), "a.txt");
@@ -1404,6 +1404,6 @@ mod test {
14041404
.map(char::from)
14051405
.take(8)
14061406
.collect();
1407-
format!("/tmp/temp_{}", name)
1407+
format!("/tmp/temp_{name}")
14081408
}
14091409
}

0 commit comments

Comments
 (0)