ctb_workspace_ipc/services/
storage.generated.rs

1// SPDX-License-Identifier: AGPL-3.0-or-later
2/*
3This file is part of Collective Toolbox, a database and document workspace and utilities.
4Copyright (C) 2026 Collective Toolbox Developers
5Contact: info@collectivetoolbox.com
6
7This program is free software: you can redistribute it and/or modify it under
8the terms of the GNU Affero General Public License as published by the Free
9Software Foundation, either version 3 of the License, or (at your option) any
10later version.
11
12This program is distributed in the hope that it will be useful, but WITHOUT ANY
13WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more details.
15
16You should have received a copy of the GNU Affero General Public License along
17with this program.  If not, see <https://www.gnu.org/licenses/>.
18*/
19
20// IPC service for storage process.
21//
22// @generated by ctb-build-support::ipc_codegen
23// Do not edit by hand.
24
25// DTO conversion helpers (service DTO -> service crate type)
26
27fn to_ctb_storage_node(v: &::ctb_utilities::ipc::service_traits::storage::Node) -> ::ctb_storage::models::node::Node {
28    ::ctb_storage::models::node::Node {
29        id: v.id.clone(),
30        graph_id: v.graph_id.clone(),
31        node_type: to_ctb_storage_node_type(&v.node_type),
32        data: v.data.clone(),
33        checksum: v.checksum.clone(),
34        timestamp: v.timestamp.clone(),
35    }
36}
37
38fn to_ctb_storage_node_type(v: &::ctb_utilities::ipc::service_traits::storage::NodeType) -> ::ctb_storage::models::node::NodeType {
39    match v {
40        ::ctb_utilities::ipc::service_traits::storage::NodeType::Data => ::ctb_storage::models::node::NodeType::Data,
41        ::ctb_utilities::ipc::service_traits::storage::NodeType::Statements => ::ctb_storage::models::node::NodeType::Statements,
42        ::ctb_utilities::ipc::service_traits::storage::NodeType::System => ::ctb_storage::models::node::NodeType::System,
43    }
44}
45
46fn to_ctb_storage_table_row(v: &::ctb_utilities::ipc::service_traits::storage::TableRow) -> ::ctb_storage::db::TableRow {
47    ::ctb_storage::db::TableRow {
48        columns: v.columns.clone(),
49        values: v.values.clone(),
50        page: v.page.clone(),
51        total_pages: v.total_pages.clone(),
52        total_rows: v.total_rows.clone(),
53    }
54}
55
56fn to_ctb_storage_user_dto(v: &::ctb_utilities::ipc::service_traits::storage::UserDto) -> ::ctb_storage::models::user_impl::UserDto {
57    ::ctb_storage::models::user_impl::UserDto {
58        id: v.id.clone(),
59        username: v.username.clone(),
60        uuid: v.uuid.clone(),
61        auth: v.auth.clone(),
62        display_name: v.display_name.clone(),
63        picture: v.picture.clone(),
64        key_encryption_key_params: v.key_encryption_key_params.clone(),
65        wrapped_dek: v.wrapped_dek.clone(),
66        pubkey: v.pubkey.clone(),
67        subscription_expiry: v.subscription_expiry.clone(),
68        token_quota: v.token_quota.clone(),
69        remote_status: v.remote_status.clone(),
70    }
71}
72
73
74ipc_service_client! {
75    service: storage,
76    methods: {
77        async fn allocate_next_remote_range(&self, graph_id: u128) -> Result<u64>
78            => ::ctb_storage::models::sync_impl::AllocateNextRemoteRangeIpcClientExt(graph_id);
79        async fn allocate_next_system_id(&self, session_token: & str) -> Result<u128>
80            => ::ctb_storage::models::graph_impl::AllocateNextSystemIdIpcClientExt(session_token.to_string());
81        async fn change_user_password(&self, username: & str, old_password_bytes: Vec < u8 >, new_password_bytes: Vec < u8 >) -> Result<()>
82            => ::ctb_storage::models::user::session::ChangeUserPasswordIpcClientExt(username.to_string(), old_password_bytes, new_password_bytes);
83        async fn create_user(&self, user: ::ctb_utilities::ipc::service_traits::storage::UserDto) -> Result<()>
84            => ::ctb_storage::models::user_impl::CreateUserIpcClientExt(to_ctb_storage_user_dto(&user));
85        async fn create_user_and_session(&self, username: & str, password_bytes: Vec < u8 >, duration_secs: u64) -> Result<String>
86            => ::ctb_storage::models::user::session::CreateUserAndSessionIpcClientExt(username.to_string(), password_bytes, duration_secs);
87        async fn delete_local_token(&self, user_id: u64, key: u64) -> Result<()>
88            => ::ctb_storage::models::sync_impl::DeleteLocalTokenIpcClientExt(user_id, key);
89        async fn delete_user_by_id(&self, id: u64) -> Result<()>
90            => ::ctb_storage::models::user_impl::DeleteUserByIdIpcClientExt(id);
91        async fn deregister_user(&self, user_id: u64) -> Result<()>
92            => ::ctb_storage::models::user::session::DeregisterUserIpcClientExt(user_id);
93        async fn get_all_user_ids(&self) -> Result<Vec < u64 >>
94            => ::ctb_storage::models::user_impl::GetAllUserIdsIpcClientExt();
95        async fn get_formatted_table_data(&self, session_token: & str, db_name: & str, table_name: & str, page: u32) -> Result<:: ctb_utilities :: ipc :: service_traits :: storage :: TableRow>
96            => ::ctb_storage::models::graph_impl::GetFormattedTableDataIpcClientExt(session_token.to_string(), db_name.to_string(), table_name.to_string(), page);
97        async fn get_local_id_range(&self, user_id: u64, graph_id: u128) -> Result<Option < Vec < u8 > >>
98            => ::ctb_storage::models::sync_impl::GetLocalIdRangeIpcClientExt(user_id, graph_id);
99        async fn get_local_tokens(&self, user_id: u64) -> Result<Vec < (u64 , String) >>
100            => ::ctb_storage::models::sync_impl::GetLocalTokensIpcClientExt(user_id);
101        async fn get_node(&self, session_token: & str, graph_id: u128, id: u128) -> Result<Option < Vec < u8 > >>
102            => ::ctb_storage::models::node_impl::GetNodeIpcClientExt(session_token.to_string(), graph_id, id);
103        async fn get_node_dto(&self, session_token: & str, graph_id: u128, id: u128) -> Result<Option < :: ctb_utilities :: ipc :: service_traits :: storage :: Node >>
104            => ::ctb_storage::models::node_impl::GetNodeDtoIpcClientExt(session_token.to_string(), graph_id, id);
105        async fn get_sync_chunk(&self, hash: & str) -> Result<Option < Vec < u8 > >>
106            => ::ctb_storage::models::sync_impl::GetSyncChunkIpcClientExt(hash.to_string());
107        async fn get_user_by_id(&self, id: u64) -> Result<Option < :: ctb_utilities :: ipc :: service_traits :: storage :: UserDto >>
108            => ::ctb_storage::models::user_impl::GetUserByIdIpcClientExt(id);
109        async fn get_user_by_name(&self, name: & str) -> Result<Option < :: ctb_utilities :: ipc :: service_traits :: storage :: UserDto >>
110            => ::ctb_storage::models::user_impl::GetUserByNameIpcClientExt(name.to_string());
111        async fn get_voprf_key(&self) -> Result<Option < Vec < u8 > >>
112            => ::ctb_storage::models::user_impl::GetVoprfKeyIpcClientExt();
113        async fn increment_and_get_user_id(&self) -> Result<u64>
114            => ::ctb_storage::models::user_impl::IncrementAndGetUserIdIpcClientExt();
115        async fn insert_node(&self, session_token: & str, graph_id: u128, node_type: ::ctb_utilities::ipc::service_traits::storage::NodeType, data: & [u8]) -> Result<u128>
116            => ::ctb_storage::models::node_impl::InsertNodeIpcClientExt(session_token.to_string(), graph_id, to_ctb_storage_node_type(&node_type), data);
117        async fn invalidate_session(&self, token: & str) -> Result<()>
118            => ::ctb_storage::models::user::session::InvalidateSessionIpcClientExt(token.to_string());
119        async fn is_token_spent(&self, serial_hex: & str) -> Result<bool>
120            => ::ctb_storage::models::sync_impl::IsTokenSpentIpcClientExt(serial_hex.to_string());
121        async fn list_databases(&self, session_token: & str) -> Result<Vec < String >>
122            => ::ctb_storage::models::graph_impl::ListDatabasesIpcClientExt(session_token.to_string());
123        async fn list_nodes(&self, session_token: & str) -> Result<Vec < :: ctb_utilities :: ipc :: service_traits :: storage :: Node >>
124            => ::ctb_storage::models::node_impl::ListNodesIpcClientExt(session_token.to_string());
125        async fn list_tables(&self, session_token: & str, db_name: & str) -> Result<Vec < String >>
126            => ::ctb_storage::models::graph_impl::ListTablesIpcClientExt(session_token.to_string(), db_name.to_string());
127        async fn login_user(&self, username: & str, password_bytes: Vec < u8 >, duration_secs: u64) -> Result<String>
128            => ::ctb_storage::models::user::session::LoginUserIpcClientExt(username.to_string(), password_bytes, duration_secs);
129        async fn publish_packaged_node_to_global(&self, session_token: & str, package: Vec < u8 >, target_id: Option < u128 >) -> Result<u128>
130            => ::ctb_storage::models::graph_impl::PublishPackagedNodeToGlobalIpcClientExt(session_token.to_string(), package, target_id);
131        async fn refresh_session(&self, token: & str, duration_secs: u64) -> Result<()>
132            => ::ctb_storage::models::user::session::RefreshSessionIpcClientExt(token.to_string(), duration_secs);
133        async fn rename_user(&self, id: u64, new_username: & str) -> Result<()>
134            => ::ctb_storage::models::user_impl::RenameUserIpcClientExt(id, new_username.to_string());
135        async fn save_local_id_range(&self, user_id: u64, graph_id: u128, range_bytes: Vec < u8 >) -> Result<()>
136            => ::ctb_storage::models::sync_impl::SaveLocalIdRangeIpcClientExt(user_id, graph_id, range_bytes);
137        async fn save_local_token(&self, user_id: u64, key: u64, token: & str) -> Result<()>
138            => ::ctb_storage::models::sync_impl::SaveLocalTokenIpcClientExt(user_id, key, token.to_string());
139        async fn save_sync_chunk(&self, hash: & str, data: Vec < u8 >, expiry: u64) -> Result<()>
140            => ::ctb_storage::models::sync_impl::SaveSyncChunkIpcClientExt(hash.to_string(), data, expiry);
141        async fn save_voprf_key(&self, key: Vec < u8 >) -> Result<()>
142            => ::ctb_storage::models::user_impl::SaveVoprfKeyIpcClientExt(key);
143        async fn spend_token(&self, serial_hex: & str) -> Result<()>
144            => ::ctb_storage::models::sync_impl::SpendTokenIpcClientExt(serial_hex.to_string());
145        async fn update_node_data(&self, session_token: & str, graph_id: u128, node_id: u128, data: Vec < u8 >) -> Result<()>
146            => ::ctb_storage::models::node_impl::UpdateNodeDataIpcClientExt(session_token.to_string(), graph_id, node_id, data);
147        async fn update_node_type(&self, session_token: & str, graph_id: u128, node_id: u128, node_type: ::ctb_utilities::ipc::service_traits::storage::NodeType) -> Result<()>
148            => ::ctb_storage::models::node_impl::UpdateNodeTypeIpcClientExt(session_token.to_string(), graph_id, node_id, to_ctb_storage_node_type(&node_type));
149        async fn update_user(&self, user: ::ctb_utilities::ipc::service_traits::storage::UserDto) -> Result<()>
150            => ::ctb_storage::models::user_impl::UpdateUserIpcClientExt(to_ctb_storage_user_dto(&user));
151        async fn validate_session(&self, token: & str) -> Result<Option < u64 >>
152            => ::ctb_storage::models::user::session::ValidateSessionIpcClientExt(token.to_string());
153    }
154}