pub struct Unit { /* private fields */ }
Expand description

The Unit application context.

This object wraps the libunit library, which talks to the Unit server over shared memory and a unix socket in order to receive data about requests.

This object is not Send nor Sync, and cannot be sent to other threads.

However, multiple objects of this type may be created; additional Unit objects will automatically be linked to the first through a global mutex, and will be able to receive and process requests in other threads.

The first context is internally wrapped in an Arc, shared among all instances Unit and will be deallocated when the last Unit object is dropped.

Implementations

Create a new Unit context capable of receiving and handling requests on the current thread.

If called after a previous Unit was constructed but already received a QUIT event from the Unit server, this will return a no-op Unit instance whose Unit::run method will immediately return.

If called after a previous Unit failed to initialize, this will return the same initialization failure.

Set a request handler for the Unit application.

The handler must be an object that implements the UnitService trait.

This trait is automatically implemented for functions or lambda functions that take a Request object and return a UnitResult<()>.

Enter the main event loop, handling requests on this thread until the Unit server exits or requests a restart.

This may be executed in parallel with other threads that call Unit::run()

Trait Implementations

Executes the destructor for this type. 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

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

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.