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