1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
use std::marker::PhantomData; pub trait PlugLifetime<'a> { type Type; } pub struct H1MutexLockGuard<T>(PhantomData<T>); impl<'a, T> PlugLifetime<'a> for H1MutexLockGuard<T> where T: 'static, { type Type = std::sync::MutexGuard<'a, T>; } #[cfg(feature = "tokio")] pub struct H1TokioMutexLockGuard<T>(PhantomData<T>); #[cfg(feature = "tokio")] impl<'a, T> PlugLifetime<'a> for H1TokioMutexLockGuard<T> where T: 'static, { type Type = tokio::sync::MutexGuard<'a, T>; } pub struct H1RwLockReadGuard<T>(PhantomData<T>); impl<'a, T> PlugLifetime<'a> for H1RwLockReadGuard<T> where T: 'static, { type Type = std::sync::RwLockReadGuard<'a, T>; } pub struct H1RwLockWriteGuard<T>(PhantomData<T>); impl<'a, T> PlugLifetime<'a> for H1RwLockWriteGuard<T> where T: 'static, { type Type = std::sync::RwLockWriteGuard<'a, T>; } #[cfg(feature = "tokio")] pub struct H1TokioRwLockReadGuard<T>(PhantomData<T>); #[cfg(feature = "tokio")] impl<'a, T> PlugLifetime<'a> for H1TokioRwLockReadGuard<T> where T: 'static, { type Type = tokio::sync::RwLockReadGuard<'a, T>; } #[cfg(feature = "tokio")] pub struct H1TokioRwLockWriteGuard<T>(PhantomData<T>); #[cfg(feature = "tokio")] impl<'a, T> PlugLifetime<'a> for H1TokioRwLockWriteGuard<T> where T: 'static, { type Type = tokio::sync::RwLockWriteGuard<'a, T>; }