Skip to content

Commit 7930792

Browse files
committed
Update to secrecy 0.10.
1 parent 7410d73 commit 7930792

File tree

4 files changed

+15
-10
lines changed

4 files changed

+15
-10
lines changed

Cargo.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ edition = "2018"
1414
log = "0.4"
1515
nom = { version = "7", default-features = false }
1616
percent-encoding = "2.1"
17-
secrecy = "0.8"
17+
secrecy = "0.10"
1818
which = { version = "4", default-features = false }
1919
zeroize = "1"

src/assuan.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,13 @@ impl Connection {
148148
let buf = data.take();
149149
let data_line_decoded =
150150
percent_decode_str(data_line.expose_secret()).decode_utf8()?;
151-
data = Some(buf.unwrap_or_else(String::new) + &data_line_decoded);
151+
152+
let mut s = buf
153+
.unwrap_or_else(|| String::new().into_boxed_str())
154+
.to_string();
155+
s.push_str(data_line_decoded.as_ref());
156+
data = Some(s.into_boxed_str());
157+
152158
if let Cow::Owned(mut data_line_decoded) = data_line_decoded {
153159
data_line_decoded.zeroize();
154160
}
@@ -174,7 +180,6 @@ mod read {
174180
sequence::{pair, preceded, terminated},
175181
IResult,
176182
};
177-
use secrecy::SecretString;
178183

179184
use super::Response;
180185

@@ -224,7 +229,7 @@ mod read {
224229
preceded(
225230
tag("D "),
226231
map(is_not("\r\n"), |data: &str| {
227-
Response::DataLine(SecretString::new(data.to_owned()))
232+
Response::DataLine(data.to_owned().into())
228233
}),
229234
),
230235
preceded(

src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
//! .interact()
1919
//! } else {
2020
//! // Fall back to some other passphrase entry method.
21-
//! Ok(SecretString::new("a better passphrase than this".to_owned()))
21+
//! Ok("a better passphrase than this".to_owned().into())
2222
//! }?;
2323
//! # Ok::<(), pinentry::Error>(())
2424
//! ```
@@ -239,7 +239,7 @@ impl<'a> PassphraseInput<'a> {
239239
loop {
240240
match (pinentry.send_request("GETPIN", None)?, self.required) {
241241
// If the user provides an empty passphrase, GETPIN returns no data.
242-
(None, None) => return Ok(SecretString::new(String::new())),
242+
(None, None) => return Ok(String::new().into()),
243243
(Some(passphrase), _) => return Ok(passphrase),
244244
(_, Some(empty_error)) => {
245245
// SETERROR is cleared by GETPIN, so we reset it on each loop.

0 commit comments

Comments
 (0)