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;
}