mirror of
https://github.com/matrix-org/matrix-rust-sdk.git
synced 2026-06-14 03:14:22 -04:00
fix(crypto): Make impl Stream return type not use any lifetime
With Rust 2024, by default `impl` return types use any generic that is in scope, so in these cases the lifetime of `self`. But since the return type is actually owned, the returned impl shouldn't use any lifetime, which is what `use<>` does. Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
This commit is contained in:
committed by
Benjamin Bouvier
parent
c7b4b5dc05
commit
ba2fe1d387
@@ -335,14 +335,14 @@ impl CryptoStoreWrapper {
|
||||
/// logged and items will be dropped.
|
||||
pub fn room_keys_withheld_received_stream(
|
||||
&self,
|
||||
) -> impl Stream<Item = Vec<RoomKeyWithheldInfo>> {
|
||||
) -> impl Stream<Item = Vec<RoomKeyWithheldInfo>> + use<> {
|
||||
let stream = BroadcastStream::new(self.room_keys_withheld_received_sender.subscribe());
|
||||
Self::filter_errors_out_of_stream(stream, "room_keys_withheld_received_stream")
|
||||
}
|
||||
|
||||
/// Receive notifications of gossipped secrets being received and stored in
|
||||
/// the secret inbox as a [`Stream`].
|
||||
pub fn secrets_stream(&self) -> impl Stream<Item = GossippedSecret> {
|
||||
pub fn secrets_stream(&self) -> impl Stream<Item = GossippedSecret> + use<> {
|
||||
let stream = BroadcastStream::new(self.secrets_broadcaster.subscribe());
|
||||
Self::filter_errors_out_of_stream(stream, "secrets_stream")
|
||||
}
|
||||
@@ -360,7 +360,8 @@ impl CryptoStoreWrapper {
|
||||
/// device and user identity streams.
|
||||
pub(super) fn identities_stream(
|
||||
&self,
|
||||
) -> impl Stream<Item = (Option<OwnUserIdentityData>, IdentityChanges, DeviceChanges)> {
|
||||
) -> impl Stream<Item = (Option<OwnUserIdentityData>, IdentityChanges, DeviceChanges)> + use<>
|
||||
{
|
||||
let stream = BroadcastStream::new(self.identities_broadcaster.subscribe());
|
||||
Self::filter_errors_out_of_stream(stream, "identities_stream")
|
||||
}
|
||||
|
||||
@@ -1151,7 +1151,7 @@ impl Store {
|
||||
/// logged and items will be dropped.
|
||||
pub fn room_keys_withheld_received_stream(
|
||||
&self,
|
||||
) -> impl Stream<Item = Vec<RoomKeyWithheldInfo>> {
|
||||
) -> impl Stream<Item = Vec<RoomKeyWithheldInfo>> + use<> {
|
||||
self.inner.store.room_keys_withheld_received_stream()
|
||||
}
|
||||
|
||||
@@ -1185,7 +1185,7 @@ impl Store {
|
||||
/// }
|
||||
/// # });
|
||||
/// ```
|
||||
pub fn user_identities_stream(&self) -> impl Stream<Item = IdentityUpdates> {
|
||||
pub fn user_identities_stream(&self) -> impl Stream<Item = IdentityUpdates> + use<> {
|
||||
let verification_machine = self.inner.verification_machine.to_owned();
|
||||
|
||||
let this = self.clone();
|
||||
@@ -1243,7 +1243,7 @@ impl Store {
|
||||
/// }
|
||||
/// # });
|
||||
/// ```
|
||||
pub fn devices_stream(&self) -> impl Stream<Item = DeviceUpdates> {
|
||||
pub fn devices_stream(&self) -> impl Stream<Item = DeviceUpdates> + use<> {
|
||||
let verification_machine = self.inner.verification_machine.to_owned();
|
||||
|
||||
self.inner.store.identities_stream().map(move |(own_identity, identities, devices)| {
|
||||
@@ -1265,7 +1265,9 @@ impl Store {
|
||||
///
|
||||
/// The stream will terminate once all references to the underlying
|
||||
/// `CryptoStoreWrapper` are dropped.
|
||||
pub fn identities_stream_raw(&self) -> impl Stream<Item = (IdentityChanges, DeviceChanges)> {
|
||||
pub fn identities_stream_raw(
|
||||
&self,
|
||||
) -> impl Stream<Item = (IdentityChanges, DeviceChanges)> + use<> {
|
||||
self.inner.store.identities_stream().map(|(_, identities, devices)| (identities, devices))
|
||||
}
|
||||
|
||||
@@ -1318,7 +1320,7 @@ impl Store {
|
||||
/// }
|
||||
/// # });
|
||||
/// ```
|
||||
pub fn secrets_stream(&self) -> impl Stream<Item = GossippedSecret> {
|
||||
pub fn secrets_stream(&self) -> impl Stream<Item = GossippedSecret> + use<> {
|
||||
self.inner.store.secrets_stream()
|
||||
}
|
||||
|
||||
|
||||
@@ -681,7 +681,7 @@ impl QrVerification {
|
||||
/// Listen for changes in the QrCode verification process.
|
||||
///
|
||||
/// The changes are presented as a stream of [`QrVerificationState`] values.
|
||||
pub fn changes(&self) -> impl Stream<Item = QrVerificationState> {
|
||||
pub fn changes(&self) -> impl Stream<Item = QrVerificationState> + use<> {
|
||||
self.state.subscribe().map(|s| (&s).into())
|
||||
}
|
||||
|
||||
|
||||
@@ -881,7 +881,7 @@ impl VerificationRequest {
|
||||
///
|
||||
/// The changes are presented as a stream of [`VerificationRequestState`]
|
||||
/// values.
|
||||
pub fn changes(&self) -> impl Stream<Item = VerificationRequestState> {
|
||||
pub fn changes(&self) -> impl Stream<Item = VerificationRequestState> + use<> {
|
||||
self.inner.subscribe().map(|s| (&s).into())
|
||||
}
|
||||
|
||||
|
||||
@@ -745,7 +745,7 @@ impl Sas {
|
||||
/// }
|
||||
/// # anyhow::Ok(()) };
|
||||
/// ```
|
||||
pub fn changes(&self) -> impl Stream<Item = SasState> {
|
||||
pub fn changes(&self) -> impl Stream<Item = SasState> + use<> {
|
||||
self.inner.subscribe().map(|s| (&s).into())
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user