Struct milter::DataHandle[][src]

pub struct DataHandle<T> { /* fields omitted */ }
Expand description

A handle on user data stored in the callback context.

DataHandle<T> serves as an accessor to connection-local data T that can be shared across callback functions within a connection.

Data life cycle

By design, data life cycle management is not automatic. It is the responsibility of a milter implementation to manage the data’s life cycle by reacquiring and disposing of context data (including associated resources such as file handles etc.) at an appropriate time in the callback flow.

As a rule of thumb, every path through the callback flow must have a final call to take.

Implementations

Hands over data into the context, returning current context data if present.

Errors

An error variant is returned if libmilter encounters an error.

Takes ownership of the current context data if present, removing it from the context.

Errors

An error variant is returned if libmilter encounters an error.

Returns a reference to (borrows) the current context data if present.

Examples
if let Some(data) = context.data.borrow() {
    println!("{}", data);
}

Returns a mutable reference to (mutably borrows) the current context data if present.

Examples
if let Some(msg_count) = context.data.borrow_mut() {
    *msg_count += 1;
}

Trait Implementations

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.