Trait LDAPOptionValue

Source
pub trait LDAPOptionValue {
    // Required method
    fn as_cvoid_ptr(&self) -> *const c_void;
}
Expand description

A trait for types that can be passed as LDAP option values.

Underlying OpenLDAP implementation calls for option values to be passed in as *const c_void, while allowing values to be i32 or String. Using traits, we implement function overloading to handle i32 and String option value types.

This trait allocates memory that a caller must free using std::boxed::Box::from_raw. This helps guarantee that there is not a use after free bug (in Rust) while providing the appearance of opaque memory to OpenLDAP (in C). In pure C, we would’ve accomplished this by casting a local variable to a const void *. In Rust, we must do this on the heap to ensure Rust’s ownership system does not free the memory used to store the option value between now and when the option is actually set.

Required Methods§

Implementations on Foreign Types§

Source§

impl LDAPOptionValue for bool

Source§

impl LDAPOptionValue for i32

Source§

impl LDAPOptionValue for str

Implementors§