Skip to content

Commit ba03ba9

Browse files
committed
PublicKey Changes + Formatting Fixes
1 parent f633922 commit ba03ba9

3 files changed

Lines changed: 11 additions & 7 deletions

File tree

ssh-key/src/dot_ssh.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,12 @@ impl DotSsh {
7272

7373
/// Write a private key into `~/.ssh`.
7474
pub fn write_private_key(&self, filename: impl AsRef<Path>, key: &PrivateKey) -> Result<()> {
75-
key.write_openssh_file(&self.path.join(filename), Default::default())
75+
key.write_openssh_file(self.path.join(filename), Default::default())
7676
}
7777

7878
/// Write a public key into `~/.ssh`.
7979
pub fn write_public_key(&self, filename: impl AsRef<Path>, key: &PublicKey) -> Result<()> {
80-
key.write_openssh_file(&self.path.join(filename))
80+
key.write_openssh_file(self.path.join(filename))
8181
}
8282
}
8383

@@ -100,7 +100,7 @@ impl Iterator for PrivateKeysIter {
100100
loop {
101101
let entry = self.read_dir.next()?.ok()?;
102102

103-
if let Ok(key) = PrivateKey::read_openssh_file(&entry.path()) {
103+
if let Ok(key) = PrivateKey::read_openssh_file(entry.path()) {
104104
return Some(key);
105105
}
106106
}
@@ -119,7 +119,7 @@ impl Iterator for PublicKeysIter {
119119
loop {
120120
let entry = self.read_dir.next()?.ok()?;
121121

122-
if let Ok(key) = PublicKey::read_openssh_file(&entry.path()) {
122+
if let Ok(key) = PublicKey::read_openssh_file(entry.path()) {
123123
return Some(key);
124124
}
125125
}

ssh-key/src/private.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,11 @@ impl PrivateKey {
366366

367367
/// Write private key as an OpenSSH-formatted PEM file.
368368
#[cfg(feature = "std")]
369-
pub fn write_openssh_file<P: AsRef<Path>>(&self, path: P, line_ending: LineEnding) -> Result<()> {
369+
pub fn write_openssh_file<P: AsRef<Path>>(
370+
&self,
371+
path: P,
372+
line_ending: LineEnding,
373+
) -> Result<()> {
370374
let pem = self.to_openssh(line_ending)?;
371375

372376
#[cfg(not(unix))]

ssh-key/src/public.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,14 +237,14 @@ impl PublicKey {
237237

238238
/// Read public key from an OpenSSH-formatted file.
239239
#[cfg(feature = "std")]
240-
pub fn read_openssh_file(path: &Path) -> Result<Self> {
240+
pub fn read_openssh_file<P: AsRef<Path>>(path: P) -> Result<Self> {
241241
let input = fs::read_to_string(path)?;
242242
Self::from_openssh(&input)
243243
}
244244

245245
/// Write public key as an OpenSSH-formatted file.
246246
#[cfg(feature = "std")]
247-
pub fn write_openssh_file(&self, path: &Path) -> Result<()> {
247+
pub fn write_openssh_file<P: AsRef<Path>>(&self, path: P) -> Result<()> {
248248
let mut encoded = self.to_openssh()?;
249249
encoded.push('\n'); // TODO(tarcieri): OS-specific line endings?
250250

0 commit comments

Comments
 (0)