syslog_rs/a_sync/async_tokio/
async_mutex.rs1use tokio::sync::{Mutex, MutexGuard};
17
18use crate::
19{
20 a_sync::syslog_async_internal::{AsyncMutex, AsyncMutexGuard, AsyncSyslogInternal, AsyncSyslogInternalIO},
21 formatters::SyslogFormatter,
22 AsyncSyslogDestination
23};
24
25
26pub type DefaultAsyncMutex<F, D, IO> = Mutex<AsyncSyslogInternal<F, D, IO>>;
27
28impl<F: SyslogFormatter + Send, D: AsyncSyslogDestination, IO: AsyncSyslogInternalIO> AsyncMutex<F, D, AsyncSyslogInternal<F, D, IO>>
29for Mutex<AsyncSyslogInternal<F, D, IO>>
30{
31 type MutxGuard<'mux> = MutexGuard<'mux, AsyncSyslogInternal<F, D, IO>>;
32
33 fn a_new(v: AsyncSyslogInternal<F, D, IO>) -> Self
34 {
35 return Mutex::new(v);
36 }
37
38 fn a_lock<'mux>(&'mux self) -> impl Future<Output = Self::MutxGuard<'mux>>
39 {
40 return self.lock();
41 }
42}
43
44impl<'mux, F: SyslogFormatter + Send, D: AsyncSyslogDestination, IO: AsyncSyslogInternalIO> AsyncMutexGuard<'mux, F, D, AsyncSyslogInternal<F, D, IO>>
45for MutexGuard<'mux, AsyncSyslogInternal<F, D, IO>>
46{
47 fn guard(&self) -> &AsyncSyslogInternal<F, D, IO>
48 {
49 return self;
50 }
51
52 fn guard_mut(&mut self) -> &mut AsyncSyslogInternal<F, D, IO>
53 {
54 return self;
55 }
56}