Struct sea_orm_rocket::Connection
source · 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 statusInternalServerError
. ASentinel
guards this condition, and so this type of failure is unlikely to occur. ANone
error is returned. - If a connection is not available within
connect_timeout
seconds or another error occurs, the gaurd fails with statusServiceUnavailable
and the error is returned inSome
.
Implementations
sourceimpl<'a, D: Database> Connection<'a, D>
impl<'a, D: Database> Connection<'a, D>
sourcepub fn into_inner(self) -> &'a <D::Pool as Pool>::Connection
pub fn into_inner(self) -> &'a <D::Pool as Pool>::Connection
Returns the internal connection value. See the Connection
Deref
column for the expected type of this value.
Trait Implementations
sourceimpl<'r, D: Database> FromRequest<'r> for Connection<'r, D>
impl<'r, D: Database> FromRequest<'r> for Connection<'r, D>
sourceimpl<'r, D: Database> OpenApiFromRequest<'r> for Connection<'r, D>
impl<'r, D: Database> OpenApiFromRequest<'r> for Connection<'r, D>
sourcefn from_request_input(
_gen: &mut OpenApiGenerator,
_name: String,
_required: bool
) -> Result<RequestHeaderInput>
fn from_request_input(
_gen: &mut OpenApiGenerator,
_name: String,
_required: bool
) -> Result<RequestHeaderInput>
Specifies what headers or other parameters are required for this Request Guards to validate
successfully. Read more
sourcefn get_responses(_gen: &mut OpenApiGenerator) -> Result<Responses, OpenApiError>
fn get_responses(_gen: &mut OpenApiGenerator) -> Result<Responses, OpenApiError>
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
Auto Trait Implementations
impl<'a, D> RefUnwindSafe for Connection<'a, D>where
<<D as Database>::Pool as Pool>::Connection: RefUnwindSafe,
impl<'a, D> Send for Connection<'a, D>where
<<D as Database>::Pool as Pool>::Connection: Sync,
impl<'a, D> Sync for Connection<'a, D>where
<<D as Database>::Pool as Pool>::Connection: Sync,
impl<'a, D> Unpin for Connection<'a, D>
impl<'a, D> UnwindSafe for Connection<'a, D>where
<<D as Database>::Pool as Pool>::Connection: RefUnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<T> IntoCollection<T> for T
impl<T> IntoCollection<T> for T
fn into_collection<A>(self) -> SmallVec<A>where
A: Array<Item = T>,
fn into_collection<A>(self) -> SmallVec<A>where
A: Array<Item = T>,
Converts
self
into a collection.