Skip to content

Commit 6180ca3

Browse files
committed
Fix streaming search lifetime without 'static
1 parent e17da56 commit 6180ca3

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/lib.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ use std::{
138138

139139
use filter::{AndFilter, EqFilter, Filter, OrFilter};
140140
use futures::{Stream, StreamExt, executor::block_on, stream};
141+
use std::pin::Pin;
141142
use ldap3::{
142143
Ldap, LdapConnAsync, LdapConnSettings, LdapError, LdapResult, Mod, Scope, SearchEntry,
143144
SearchStream, StreamState,
@@ -656,7 +657,7 @@ impl LdapClient {
656657
scope: Scope,
657658
filter: &F,
658659
attributes: A,
659-
) -> Result<impl Stream<Item = Result<Record, Error>> + use<'a, F, A, S>, Error>
660+
) -> Result<Pin<Box<dyn Stream<Item = Result<Record, Error>> + 'a>>, Error>
660661
where
661662
F: Filter,
662663
A: AsRef<[S]> + Send + Sync + 'a,
@@ -778,7 +779,7 @@ impl LdapClient {
778779
filter: &F,
779780
attributes: A,
780781
page_size: i32,
781-
) -> Result<impl Stream<Item = Result<Record, Error>> + use<'a, F, A, S>, Error>
782+
) -> Result<Pin<Box<dyn Stream<Item = Result<Record, Error>> + 'a>>, Error>
782783
where
783784
F: Filter,
784785
// PagedResults requires Clone and Debug too.
@@ -1789,7 +1790,7 @@ where
17891790
/// A helper to create native rust streams out of `ldap3::SearchStream`s.
17901791
fn to_native_stream<'a, S, A>(
17911792
ldap3_stream: SearchStream<'a, S, A>,
1792-
) -> Result<impl Stream<Item = Result<Record, Error>> + use<'a, S, A>, Error>
1793+
) -> Result<Pin<Box<dyn Stream<Item = Result<Record, Error>> + 'a>>, Error>
17931794
where
17941795
S: AsRef<str> + Send + Sync + 'a,
17951796
A: AsRef<[S]> + Send + Sync + 'a,
@@ -1818,7 +1819,7 @@ where
18181819
}
18191820
});
18201821

1821-
Ok(stream)
1822+
Ok(Box::pin(stream))
18221823
}
18231824

18241825
/// The Record struct is used to map the search result to a struct.

0 commit comments

Comments
 (0)