Struct rsasl::session::Session[][src]

pub struct Session<D> { /* fields omitted */ }

The context of an authentication exchange

This struct will call the necesarry initializers on construction and finalizers when discarded. If manual housekeeping is required the session can be leaked with DiscardOnDrop::leak.

Implementations

impl<D> Session<D>[src]

pub fn step(&mut self, input: &[u8]) -> StepResult<SaslBuffer>[src]

Perform one step of SASL authentication. This reads data from input then processes it, potentially calling a configured callback for required properties or enact decisions, and finally returns data to be send to the other party.

Note: This function may leak memory on internal failure.

pub fn step64(&mut self, input: &CStr) -> StepResult<SaslString>[src]

A simple wrapper around the gsasl step function that base64-decodes the input and base64-encodes the output. Mainly useful for text-based protocols.

Note: This function may leak memory on failure since the internal step function does as well.

pub fn set_property(&mut self, prop: Property, data: &[u8])[src]

Set a property in the session context

A property in this context is a piece of information used by authentication mechanisms, for example the Authcid, Authzid and Password for PLAIN. This is the Rust equivalent to the gsasl_property_set funciton.

pub fn get_property(&self, prop: Property) -> Option<&CStr>[src]

Try to read a property from the session context

This maps to gsasl_property_fast meaning it will not call the callback to retrieve properties it does not know about.

Returns None if the property is now known or was not set

pub fn store(&mut self, data: Box<D>)[src]

Store some data in the Session context

This allows a callback to later access that data using retrieve or retrieve_mut

pub unsafe fn retrieve(&mut self) -> Option<Box<D>>[src]

Retrieve the data stored with store, leaving nothing in its place

This function will return None if no data was stored. This function is unsafe because we can not guarantee that there is currently nothing else that has a reference to the data which will turn into a dangling pointer if the returned Box is dropped

pub fn retrieve_mut(&mut self) -> Option<&mut D>[src]

Retrieve a mutable reference to the data stored with store

This is an alternative to retrieve_raw that does not take ownership of the stored data, thus also not dropping it after it has left the current scope.

The function tries to return None if no data was stored.

Trait Implementations

impl<D: Debug> Debug for Session<D>[src]

impl<D> Discard for Session<D>[src]

Auto Trait Implementations

impl<D> RefUnwindSafe for Session<D> where
    D: RefUnwindSafe

impl<D> !Send for Session<D>

impl<D> !Sync for Session<D>

impl<D> Unpin for Session<D> where
    D: Unpin

impl<D> UnwindSafe for Session<D> where
    D: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.