pub struct Connection<'a, D: Database>(_);
Expand description

A request guard which retrieves a single connection to a Database.

For a database type of Db, a request guard of Connection<Db> retrieves a single connection to Db.

The request guard succeeds if the database was initialized by the Initializer fairing and a connection is available within connect_timeout seconds.

  • If the Initializer fairing was not attached, the guard fails with status InternalServerError. A Sentinel guards this condition, and so this type of failure is unlikely to occur. A None error is returned.
  • If a connection is not available within connect_timeout seconds or another error occurs, the gaurd fails with status ServiceUnavailable and the error is returned in Some.

Implementations

Returns the internal connection value. See the Connection Deref column for the expected type of this value.

Trait Implementations

The associated error to be returned if derivation fails.
Derives an instance of Self from the incoming request metadata. Read more
Specifies what headers or other parameters are required for this Request Guards to validate successfully. Read more
Optionally add responses to the Request Guard. This can be used for when the request guard could return a “401 Unauthorized”. Or any other responses, other then one from the default response. Read more
Returns true if launch should be aborted and false otherwise.

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.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

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

Converts self into a collection.
Should always be Self
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.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more