Skip to content

Commit 7c5099f

Browse files
committed
Add Send + Sync to IdentityFile::into_identities output
1 parent d7c727a commit 7c5099f

File tree

5 files changed

+16
-7
lines changed

5 files changed

+16
-7
lines changed

age/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ and this project adheres to Rust's notion of
99
to 1.0.0 are beta releases.
1010

1111
## [Unreleased]
12+
### Changed
13+
- `age::IdentityFile::into_identities` now returns
14+
`Result<Vec<Box<dyn crate::Identity + Send + Sync>>, DecryptError>` instead of
15+
`Result<Vec<Box<dyn crate::Identity>>, DecryptError>`. This re-enables
16+
cross-thread uses of `IdentityFile`, which were unintentionally disabled in
17+
0.11.0.
1218

1319
## [0.6.1, 0.7.2, 0.8.2, 0.9.3, 0.10.1, 0.11.1] - 2024-11-18
1420
### Security

age/src/cli_common/identities.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ pub fn read_identities(
5252
#[cfg(not(feature = "plugin"))]
5353
let new_identities = new_identities.unwrap();
5454

55-
identities.extend(new_identities);
55+
identities.extend(new_identities.into_iter().map(|i| i as _));
5656

5757
Ok(())
5858
},

age/src/encrypted.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ impl<R: io::Read, C: Callbacks> Identity<R, C> {
138138
) -> Option<Result<age_core::format::FileKey, DecryptError>>
139139
where
140140
F: Fn(
141-
Result<Box<dyn crate::Identity>, DecryptError>,
141+
Result<Box<dyn crate::Identity + Send + Sync>, DecryptError>,
142142
) -> Option<Result<age_core::format::FileKey, DecryptError>>,
143143
{
144144
match self.state.take().decrypt(self.filename.as_deref()) {

age/src/identity.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ impl IdentityFileEntry {
2525
pub(crate) fn into_identity(
2626
self,
2727
callbacks: impl Callbacks,
28-
) -> Result<Box<dyn crate::Identity>, DecryptError> {
28+
) -> Result<Box<dyn crate::Identity + Send + Sync>, DecryptError> {
2929
match self {
3030
IdentityFileEntry::Native(i) => Ok(Box::new(i)),
3131
#[cfg(feature = "plugin")]
@@ -184,14 +184,17 @@ impl<C: Callbacks> IdentityFile<C> {
184184
/// Returns the identities in this file.
185185
pub(crate) fn to_identities(
186186
&self,
187-
) -> impl Iterator<Item = Result<Box<dyn crate::Identity>, DecryptError>> + '_ {
187+
) -> impl Iterator<Item = Result<Box<dyn crate::Identity + Send + Sync>, DecryptError>> + '_
188+
{
188189
self.identities
189190
.iter()
190191
.map(|entry| entry.clone().into_identity(self.callbacks.clone()))
191192
}
192193

193194
/// Returns the identities in this file.
194-
pub fn into_identities(self) -> Result<Vec<Box<dyn crate::Identity>>, DecryptError> {
195+
pub fn into_identities(
196+
self,
197+
) -> Result<Vec<Box<dyn crate::Identity + Send + Sync>>, DecryptError> {
195198
self.identities
196199
.into_iter()
197200
.map(|entry| entry.into_identity(self.callbacks.clone()))

age/src/protocol.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ mod tests {
457457
let pk: x25519::Recipient = crate::x25519::tests::TEST_PK.parse().unwrap();
458458
recipient_round_trip(
459459
iter::once(&pk as _),
460-
f.into_identities().unwrap().iter().map(|i| i.as_ref()),
460+
f.into_identities().unwrap().iter().map(|i| i.as_ref() as _),
461461
);
462462
}
463463

@@ -469,7 +469,7 @@ mod tests {
469469
let pk: x25519::Recipient = crate::x25519::tests::TEST_PK.parse().unwrap();
470470
recipient_async_round_trip(
471471
iter::once(&pk as _),
472-
f.into_identities().unwrap().iter().map(|i| i.as_ref()),
472+
f.into_identities().unwrap().iter().map(|i| i.as_ref() as _),
473473
);
474474
}
475475

0 commit comments

Comments
 (0)