I'm using trait objects to abstract over the database engine. I have Database and Snapshot traits that can be implemented for different database engines, but I can't figure out how to return the Snapshot trait object without using unsafe.
use std::marker::PhantomData;
use std::mem;
use std::sync::Arc;
pub trait Database: Send + Sync + 'static {
    fn snapshot(&self) -> Box<dyn Snapshot>;
}
trait Snapshot: 'static {
    fn foo(&self);
}
struct DB {}
struct DBSnapshot<'a> {
    _lifetime: PhantomData<&'a ()>,
}
impl DB {
    fn snapshot(&self) -> DBSnapshot {
        DBSnapshot {
            _lifetime: PhantomData,
        }
    }
}
struct DBWrapper {
    db: Arc<DB>,
}
impl Database for DBWrapper {
    fn snapshot(&self) -> Box<dyn Snapshot> {
        Box::new(DBWrapperSnapshot {
            snapshot: self.db.snapshot(),
            // Will work with `transmute`
            // snapshot: unsafe { mem::transmute(self.db.snapshot()) },
            db: Arc::clone(&self.db),
        })
    }
}
struct DBWrapperSnapshot {
    snapshot: DBSnapshot<'static>,
    db: Arc<DB>,
}
impl Snapshot for DBWrapperSnapshot {
    fn foo(&self) {}
}
Without unsafe I get the error:
error[E0495]: cannot infer an appropriate lifetime for lifetime parameter in function call due to conflicting requirements
  --> src/main.rs:32:35
   |
32 |                 snapshot: self.db.snapshot(),
   |                                   ^^^^^^^^
   |
note: first, the lifetime cannot outlive the anonymous lifetime #1 defined on the method body at 30:9...
  --> src/main.rs:30:9
   |
30 | /         fn snapshot(&self) -> Box<dyn Snapshot> {
31 | |             Box::new(DBWrapperSnapshot {
32 | |                 snapshot: self.db.snapshot(),
33 | |                 // Will work with `transmute`
...  |
36 | |             })
37 | |         }
   | |_________^
note: ...so that reference does not outlive borrowed content
  --> src/main.rs:32:27
   |
32 |                 snapshot: self.db.snapshot(),
   |                           ^^^^^^^
   = note: but, the lifetime must be valid for the static lifetime...
   = note: ...so that the expression is assignable:
           expected DBSnapshot<'static>
              found DBSnapshot<'_>
The error is perfectly reasonable, but is it possible to avoid using transmute here? Because I want to be sure that snapshot field in DBWrapperSnapshot will not outlive reference to self.db.
Link to playground
