Skip to content

How to set pool options with rocket-sync-db-pools #2752

Answered by 5-pebbles
5-pebbles asked this question in Questions
Discussion options

You must be logged in to vote

I figured out a workaround, but if there is a better way please let me know:
 

use rocket::{serde, Build, Rocket};
use rocket_sync_db_pools::{
   database, r2d2,
   rusqlite::{self, Error},
   Config, PoolResult, Poolable,
};

use std::ops::{Deref, DerefMut};
use std::path::{Path, PathBuf};
use std::time::Duration;

I wrote a wrapper for rusqlite::Connection which implements rocket_sync_db_pools::Poolable & std::ops::{Deref, DerefMut} traits so it can be used as a replacement.

pub struct MyConnection(rusqlite::Connection);

impl Poolable for MyConnection {
    type Manager = MyManager;
    type Error = std::convert::Infallible;

    fn pool(db_name: &str, rocket: &Rocket<Build>) -> PoolResult

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by 5-pebbles
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant