use std::collections::HashMap;
use crate::Value;
pub trait AuthenticationBinding {
fn client_id(&self) -> Option<String>;
fn client_name(&self) -> Option<String>;
fn principal(&self) -> Option<String>;
fn properties(&self) -> Option<Value>;
fn properties_map(&self) -> HashMap<String, Value>;
}
impl<K: AuthenticationBinding> AuthenticationBinding for Option<K> {
fn client_id(&self) -> Option<String> {
self.as_ref().and_then(K::client_id)
}
fn client_name(&self) -> Option<String> {
self.as_ref().and_then(K::client_name)
}
fn principal(&self) -> Option<String> {
self.as_ref().and_then(K::principal)
}
fn properties(&self) -> Option<Value> {
self.as_ref().and_then(K::properties)
}
fn properties_map(&self) -> HashMap<String, Value> {
self.as_ref().map(K::properties_map).unwrap_or_default()
}
}