Question about the extractor in the tokio-postgres
example
#1757
-
While I’m reading the example: I found this part of code magical: type ConnectionPool = Pool<PostgresConnectionManager<NoTls>>;
...
#[async_trait]
impl<S> FromRequestParts<S> for DatabaseConnection
where
ConnectionPool: FromRef<S>,
S: Send + Sync,
{
type Rejection = (StatusCode, String);
async fn from_request_parts(_parts: &mut Parts, state: &S) -> Result<Self, Self::Rejection> {
let pool = ConnectionPool::from_ref(state);
let conn = pool.get_owned().await.map_err(internal_error)?;
Ok(Self(conn))
}
} I’m not sure how the above |
Beta Was this translation helpful? Give feedback.
Answered by
davidpdrsn
Feb 14, 2023
Replies: 1 comment 1 reply
-
That's just a regular trait bound. |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
Moicen
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
That's just a regular trait bound.