Skip to content

Commit

Permalink
age: Return Box<dyn Identity + Send + Sync> from read_identities
Browse files Browse the repository at this point in the history
This exposes `Send + Sync` (which is always present for `Identity` types
that we parse) to users that require it, without adding bounds to
`Identity` itself. Users who do not require these bounds can map the
output of `read_identities` to drop them.
  • Loading branch information
str4d committed May 14, 2021
1 parent 1e4d339 commit 68d6d12
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions age/src/cli_common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ pub fn read_identities<E, G>(
filenames: Vec<String>,
file_not_found: G,
#[cfg(feature = "ssh")] unsupported_ssh: impl Fn(String, crate::ssh::UnsupportedKey) -> E,
) -> Result<Vec<Box<dyn Identity>>, E>
) -> Result<Vec<Box<dyn Identity + Send + Sync>>, E>
where
E: From<crate::DecryptError>,
E: From<io::Error>,
G: Fn(String) -> E,
{
let mut identities: Vec<Box<dyn Identity>> = vec![];
let mut identities: Vec<Box<dyn Identity + Send + Sync>> = vec![];

#[cfg(feature = "plugin")]
let mut plugin_identities: Vec<plugin::Identity> = vec![];
Expand Down Expand Up @@ -68,7 +68,7 @@ where
identities.extend(
new_ids
.into_iter()
.map(|i| Box::new(i) as Box<dyn Identity>),
.map(|i| Box::new(i) as Box<dyn Identity + Send + Sync>),
);

#[cfg(feature = "plugin")]
Expand Down
2 changes: 1 addition & 1 deletion rage/src/bin/rage-mount/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ fn main() -> Result<(), Error> {
}

decryptor
.decrypt(identities.iter().map(|i| &**i))
.decrypt(identities.iter().map(|i| i.as_ref() as &dyn age::Identity))
.map_err(|e| e.into())
.and_then(|stream| mount_stream(stream, types, mountpoint))
}
Expand Down

0 comments on commit 68d6d12

Please sign in to comment.