Struct ldap3::LdapConnAsync

source ·
pub struct LdapConnAsync { /* private fields */ }
Expand description

Asynchronous connection to an LDAP server. *

In this version of the interface, opening a connection with new() will return a tuple consisting of the connection itself and an Ldap handle for performing the LDAP operations. The connection must be spawned on the active Tokio executor before using the handle. A convenience macro, drive!, is provided by the library. For the connection conn, it does the equivalent of:

tokio::spawn(async move {
    if let Err(e) = conn.drive().await {
        warn!("LDAP connection error: {}", e);
    }
});

If you need custom connection lifecycle handling, use the drive() method on the connection inside your own async block.

The Ldap handle can be freely cloned, with each clone capable of launching a separate LDAP operation multiplexed on the original connection. Dropping the last handle will automatically close the connection.

Some connections need additional parameters, but providing many separate functions to initialize them, singly or in combination, would result in a cumbersome interface. Instead, connection initialization is optimized for the expected most frequent usage, and additional customization is possible through the LdapConnSettings struct, which can be passed to with_settings().

Implementations§

source§

impl LdapConnAsync

source

pub async fn with_settings( settings: LdapConnSettings, url: &str ) -> Result<(Self, Ldap)>

Open a connection to an LDAP server specified by url, using settings to specify additional parameters.

source

pub async fn new(url: &str) -> Result<(Self, Ldap)>

Open a connection to an LDAP server specified by url.

The url is an LDAP URL. Depending on the platform and compile-time features, the library will recognize one or more URL schemes.

The ldap scheme, which uses a plain TCP connection, is always available. Unix-like platforms also support ldapi, using Unix domain sockets. With the tls or tls-rustls feature, the ldaps scheme and StartTLS over ldap are additionally supported.

The connection element in the returned tuple must be spawned on the current Tokio executor before using the Ldap element. See the introduction to this struct’s documentation.

source

pub async fn from_url_with_settings( settings: LdapConnSettings, url: &Url ) -> Result<(Self, Ldap)>

Open a connection to an LDAP server specified by an already parsed Url, using settings to specify additional parameters.

source

pub async fn from_url(url: &Url) -> Result<(Self, Ldap)>

Open a connection to an LDAP server specified by an already parsed Url.

source

pub async fn drive(self) -> Result<()>

Repeatedly poll the connection until it exits.

Auto Trait Implementations§

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