sentc_crypto_utils/
group.rs1use alloc::string::String;
2
3use sentc_crypto_common::group::GroupUserAccessBy;
4use sentc_crypto_common::GroupId;
5use serde::{Deserialize, Serialize};
6
7pub fn get_access_by(access_by: GroupUserAccessBy) -> (Option<GroupId>, Option<GroupId>)
8{
9 match access_by {
10 GroupUserAccessBy::User => (None, None),
11 GroupUserAccessBy::Parent(id) => (None, Some(id)),
12 GroupUserAccessBy::GroupAsUser(id) => (Some(id), None),
13 GroupUserAccessBy::GroupAsUserAsParent {
14 parent,
15 group_as_user,
16 } => (Some(group_as_user), Some(parent)),
17 }
18}
19
20pub struct GroupOutDataLight
21{
22 pub group_id: GroupId,
23 pub parent_group_id: Option<GroupId>,
24 pub rank: i32,
25 pub created_time: u128,
26 pub joined_time: u128,
27 pub access_by_group_as_member: Option<GroupId>,
28 pub access_by_parent_group: Option<GroupId>,
29 pub is_connected_group: bool,
30}
31
32#[derive(Serialize, Deserialize)]
35pub struct GroupOutDataLightExport
36{
37 pub group_id: String,
38 pub parent_group_id: Option<GroupId>,
39 pub rank: i32,
40 pub created_time: u128,
41 pub joined_time: u128,
42 pub access_by_group_as_member: Option<GroupId>,
43 pub access_by_parent_group: Option<GroupId>,
44 pub is_connected_group: bool,
45}
46
47impl From<GroupOutDataLight> for GroupOutDataLightExport
48{
49 fn from(value: GroupOutDataLight) -> Self
50 {
51 Self {
52 group_id: value.group_id,
53 parent_group_id: value.parent_group_id,
54 rank: value.rank,
55 created_time: value.created_time,
56 joined_time: value.joined_time,
57 access_by_group_as_member: value.access_by_group_as_member,
58 access_by_parent_group: value.access_by_parent_group,
59 is_connected_group: value.is_connected_group,
60 }
61 }
62}