Skip to content

Combining axum's FromRequestParts with diesel_async's SyncConnectionWrapper, SqliteConnection, and deadpool Pool? #196

Closed Answered by tibbe
tibbe asked this question in Q&A
Discussion options

You must be logged in to vote

Here's a final, working version:

use async_trait::async_trait;
use axum::extract::{FromRef, FromRequestParts};
use axum::http::request::Parts;
use deadpool::managed::Object;
use diesel::sqlite::SqliteConnection;
use diesel_async::pooled_connection::deadpool::Pool;
use diesel_async::pooled_connection::deadpool::{BuildError, Hook, HookError};
use diesel_async::pooled_connection::AsyncDieselConnectionManager;
use diesel_async::sync_connection_wrapper::SyncConnectionWrapper;
use diesel_async::SimpleAsyncConnection;

use crate::error_handling::AppError;

pub type PoolState = Pool<SyncConnectionWrapper<SqliteConnection>>;

#[derive(Clone)]
pub struct AppState {
    pub pool: PoolState,
}

impl F…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@tibbe
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by tibbe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants