Struct ldap3::SearchStream

source ·
pub struct SearchStream<'a, S, A> {
    pub res: Option<LdapResult>,
    /* private fields */
}
Expand description

Asynchronous handle for obtaining a stream of search results. *

User code can’t construct a stream directly, but only by using streaming_search() or streaming_search_with() on an Ldap handle.

A streaming search should be used for situations where the expected size of result entries varies considerably between searches, and/or can rise above a few tens to hundreds of KB. This is more of a concern for a long-lived process which is expected to have a predictable memory footprint (i.e., a server), but can also help with one-off searches if the result set is in the tens of thounsands of entries.

Once initiated, a streaming search is driven to the end by repeatedly calling next() until it returns Ok(None) or an error. Then, a call to finish() will return the overall result of the search. Calling finish() earlier will terminate search result processing in the client; it is the user’s responsibility to inform the server that the operation has been terminated by performing an Abandon or a Cancel operation.

There are two variants of SearchStream, direct and adapted. The former calls stream operations directly, while the latter first passes through a chain of adapters given at the time of stream creation.

Fields§

§res: Option<LdapResult>

Implementations§

source§

impl<'a, S, A> SearchStream<'a, S, A>where S: AsRef<str> + Send + Sync + 'a, A: AsRef<[S]> + Send + Sync + 'a,

source

pub async fn start( &mut self, base: &str, scope: Scope, filter: &str, attrs: A ) -> Result<()>

Initialize a streaming Search.

This method exists as an initialization point for search adapters, and is not meant for calling from regular user code. It must be public for user-defined adapters to work, but explicitly calling it on a SearchStream handle is a no-op: it will immediately return Ok(()).

source

pub async fn next(&mut self) -> Result<Option<ResultEntry>>

Fetch the next item from the result stream after executing the adapter chain if there is one.

Returns Ok(None) at the end of the stream.

source

pub async fn finish(&mut self) -> LdapResult

Return the overall result of the Search.

This method can be called at any time. If the stream has been read to the end, the return value will be the actual result returned by the server. Otherwise, a synthetic cancellation result is returned, and it’s the user’s responsibility to abandon or cancel the operation on the server.

If the Search is adapted, this method will first execute the finish() methods of all adapters in the chain.

source

pub async fn adapter_chain_tail( &mut self ) -> Vec<Box<dyn Adapter<'a, S, A> + 'a>>

Return a vector of the remaining adapters in the chain at the point of the method call. Adapter instances are cloned and collected into the resulting vector. The purpose of this method is to enable uniformly configured Search calls on the connections newly opened in an adapter.

source

pub fn state(&self) -> StreamState

Return the current state of the stream.

source

pub fn ldap_handle(&mut self) -> &mut Ldap

Return the Ldap handle of the stream.

Mutating the public elements of Ldap through the obtained handle can’t affect the current operation except in the start() chain of an adapted streaming Search, intentionally so.

Trait Implementations§

source§

impl<'a, S: Debug, A: Debug> Debug for SearchStream<'a, S, A>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a, S, A> !RefUnwindSafe for SearchStream<'a, S, A>

§

impl<'a, S, A> Send for SearchStream<'a, S, A>

§

impl<'a, S, A> Sync for SearchStream<'a, S, A>

§

impl<'a, S, A> Unpin for SearchStream<'a, S, A>

§

impl<'a, S, A> !UnwindSafe for SearchStream<'a, S, A>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more