reifydb_core/interface/catalog/
identity.rs1use reifydb_value::value::{
5 Value,
6 identity::{IdentityId, IdentityKind},
7 value_type::ValueType,
8};
9use serde::{Deserialize, Serialize};
10
11pub type RoleId = u64;
12
13pub type IdentityAttributeId = u64;
14
15#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
16pub struct Identity {
17 pub id: IdentityId,
18 pub name: String,
19 pub enabled: bool,
20 pub kind: IdentityKind,
21}
22
23impl Identity {
24 pub fn name(&self) -> &str {
25 &self.name
26 }
27
28 pub fn resolved_kind(&self) -> IdentityKind {
29 self.id.sentinel_kind().unwrap_or(self.kind)
30 }
31}
32
33#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
34pub struct Role {
35 pub id: RoleId,
36 pub name: String,
37}
38
39impl Role {
40 pub fn name(&self) -> &str {
41 &self.name
42 }
43}
44
45#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
46pub struct GrantedRole {
47 pub identity: IdentityId,
48 pub role_id: RoleId,
49}
50
51#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
52pub struct IdentityAttribute {
53 pub id: IdentityAttributeId,
54 pub name: String,
55 pub value_type: ValueType,
56}
57
58impl IdentityAttribute {
59 pub fn name(&self) -> &str {
60 &self.name
61 }
62}
63
64#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
65pub struct IdentityAttributeValue {
66 pub identity: IdentityId,
67 pub attribute: IdentityAttributeId,
68 pub value: Value,
69}