pdk_script/bindings/
authentication.rs1use std::collections::HashMap;
6
7use crate::Value;
8
9pub trait AuthenticationBinding {
11 fn client_id(&self) -> Option<String>;
13
14 fn client_name(&self) -> Option<String>;
16
17 fn principal(&self) -> Option<String>;
19
20 fn properties(&self) -> Option<Value>;
22
23 fn properties_map(&self) -> HashMap<String, Value>;
25}
26
27impl<K: AuthenticationBinding> AuthenticationBinding for Option<K> {
28 fn client_id(&self) -> Option<String> {
29 self.as_ref().and_then(K::client_id)
30 }
31
32 fn client_name(&self) -> Option<String> {
33 self.as_ref().and_then(K::client_name)
34 }
35
36 fn principal(&self) -> Option<String> {
37 self.as_ref().and_then(K::principal)
38 }
39
40 fn properties(&self) -> Option<Value> {
41 self.as_ref().and_then(K::properties)
42 }
43
44 fn properties_map(&self) -> HashMap<String, Value> {
45 self.as_ref().map(K::properties_map).unwrap_or_default()
46 }
47}