use crate::api::AuthResponseSuccess;
use parking_lot::Mutex;
use std::sync::Arc;
pub(crate) type OnSuccessInner = Box<dyn FnMut(AuthResponseSuccess) + Send>;
#[derive(Clone)]
pub struct OnSuccess(pub(crate) Arc<Mutex<OnSuccessInner>>);
impl<F> From<F> for OnSuccess
where
F: FnMut(AuthResponseSuccess) + Send + 'static,
{
fn from(f: F) -> Self {
OnSuccess(Arc::new(Mutex::new(Box::new(f))))
}
}
pub(crate) type OnErrorInner = Box<dyn FnMut(Option<String>) + Send>;
#[derive(Clone)]
pub struct OnError(pub(crate) Arc<Mutex<OnErrorInner>>);
impl<F> From<F> for OnError
where
F: FnMut(Option<String>) + Send + 'static,
{
fn from(f: F) -> Self {
OnError(Arc::new(Mutex::new(Box::new(f))))
}
}