ic_auth_client/util/
callback.rs1use crate::api::AuthResponseSuccess;
4use parking_lot::Mutex;
5use std::sync::Arc;
6
7pub(crate) type OnSuccessInner = Box<dyn FnMut(AuthResponseSuccess) + Send>;
8
9#[derive(Clone)]
20pub struct OnSuccess(pub(crate) Arc<Mutex<OnSuccessInner>>);
21
22impl<F> From<F> for OnSuccess
23where
24 F: FnMut(AuthResponseSuccess) + Send + 'static,
25{
26 fn from(f: F) -> Self {
27 OnSuccess(Arc::new(Mutex::new(Box::new(f))))
28 }
29}
30
31pub(crate) type OnErrorInner = Box<dyn FnMut(Option<String>) + Send>;
32
33#[derive(Clone)]
44pub struct OnError(pub(crate) Arc<Mutex<OnErrorInner>>);
45
46impl<F> From<F> for OnError
47where
48 F: FnMut(Option<String>) + Send + 'static,
49{
50 fn from(f: F) -> Self {
51 OnError(Arc::new(Mutex::new(Box::new(f))))
52 }
53}