use crate::common::*;
use crate::io::tls::MayBeTls;
use crate::smtp::SmtpContext;
use std::ops::Deref;
pub trait SessionService: fmt::Debug {
fn prepare_session<'a, 'i, 's, 'f>(
&'a self,
io: &'i mut Box<dyn MayBeTls>,
state: &'s mut SmtpContext,
) -> S1Fut<'f, ()>
where
'a: 'f,
'i: 'f,
's: 'f;
}
impl<S: SessionService + ?Sized, T: Deref<Target = S>> SessionService for T
where
T: fmt::Debug + Send + Sync,
S: Sync,
{
fn prepare_session<'a, 'i, 's, 'f>(
&'a self,
io: &'i mut Box<dyn MayBeTls>,
state: &'s mut SmtpContext,
) -> S1Fut<'f, ()>
where
'a: 'f,
'i: 'f,
's: 'f,
{
Box::pin(async move { S::prepare_session(Deref::deref(self), io, state).await })
}
}
impl SessionService for Dummy {
fn prepare_session<'a, 'i, 's, 'f>(
&'a self,
_io: &'i mut Box<dyn MayBeTls>,
_state: &'s mut SmtpContext,
) -> S1Fut<'f, ()>
where
'a: 'f,
'i: 'f,
's: 'f,
{
Box::pin(ready(()))
}
}