use tokio::sync::{Mutex, MutexGuard};
use crate::
{
a_sync::syslog_async_internal::{AsyncMutex, AsyncMutexGuard, AsyncSyslogInternal, AsyncSyslogInternalIO},
formatters::SyslogFormatter,
AsyncSyslogDestination
};
pub type DefaultAsyncMutex<F, D, IO> = Mutex<AsyncSyslogInternal<F, D, IO>>;
impl<F: SyslogFormatter + Send, D: AsyncSyslogDestination, IO: AsyncSyslogInternalIO> AsyncMutex<F, D, AsyncSyslogInternal<F, D, IO>>
for Mutex<AsyncSyslogInternal<F, D, IO>>
{
type MutxGuard<'mux> = MutexGuard<'mux, AsyncSyslogInternal<F, D, IO>>;
fn a_new(v: AsyncSyslogInternal<F, D, IO>) -> Self
{
return Mutex::new(v);
}
fn a_lock<'mux>(&'mux self) -> impl Future<Output = Self::MutxGuard<'mux>>
{
return self.lock();
}
}
impl<'mux, F: SyslogFormatter + Send, D: AsyncSyslogDestination, IO: AsyncSyslogInternalIO> AsyncMutexGuard<'mux, F, D, AsyncSyslogInternal<F, D, IO>>
for MutexGuard<'mux, AsyncSyslogInternal<F, D, IO>>
{
fn guard(&self) -> &AsyncSyslogInternal<F, D, IO>
{
return self;
}
fn guard_mut(&mut self) -> &mut AsyncSyslogInternal<F, D, IO>
{
return self;
}
}