diff --git a/src/cloud_extension/src/ipc_conn/connect.rs b/src/cloud_extension/src/ipc_conn/connect.rs new file mode 100644 index 0000000000000000000000000000000000000000..535265a51912d7bd08851724ab9d1eb9f62fccf8 --- /dev/null +++ b/src/cloud_extension/src/ipc_conn/connect.rs @@ -0,0 +1,190 @@ +// Copyright (c) 2023 Huawei Device Co., Ltd. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +use std::collections::HashMap; + +pub struct AppInfo { + app_bundle_name: String, + app_id: String, + app_fingerprint: String, + // And more... +} + +pub enum CloudStatus { + Unknown, + UnActivated, + Login, + Logout, +} +pub enum SpaceStatus { + Normal, + Full, +} +pub struct UserInfo { + account_id: String, + cloud_status: CloudStatus, + space_status: SpaceStatus, + total_space: u64, + left_space: u64, + // And more... +} + +pub struct Connect { + infos: HashMap, +} + +impl Connect { + pub fn new() -> Self { + todo!() + } + + pub fn get(user_id: i32) -> Infos { + todo!() + } +} + +pub struct Infos { + app_infos: HashMap, + user_infos: UserInfo, +} + +impl Infos { + pub fn get_app_info(&self) -> &AppInfo { + todo!() + } + + pub fn get_user_info(&self) -> &UserInfo { + todo!() + } +} + +pub struct RecordResponse { + time: i64, + device_name: String, + app_id: String, +} + +pub enum OperationType { + None, + Add, + Update, + Delete, +} + +pub struct Asset { + uri: String, + asset_name: String, + operation_type: OperationType, + hash: String, + version: u64, + asset_id: String, + sub_path: String, +} + +pub struct Reference { + record_id: String, + record_type: String, +} + +pub enum RecordField { + Null(), + Int(i64), + Double(f64), + String(String), + Bool(bool), + Blob(Vec), + List(Vec), + Map(HashMap), + Asset(Asset), + Reference(Reference), +} + +pub struct Record { + record_id: String, + record_type: String, + create_info: RecordResponse, + modified_info: RecordResponse, + record_data: HashMap, + is_delete: bool, + version: u32, + is_new_create: bool, +} + +impl Record { + pub fn get_record_id(&self) -> &str { + self.record_id.as_str() + } + + pub fn get_record_type(&self) -> &str { + self.record_type.as_str() + } + + pub fn get_create_info(&self) -> &RecordResponse { + &self.create_info + } + + pub fn get_modified_info(&self) -> &RecordResponse { + &self.modified_info + } + + pub fn get_record_data(&self) -> &HashMap { + &self.record_data + } + + pub fn get_is_delete(&self) -> bool { + self.is_delete + } + + pub fn get_version(&self) -> u32 { + self.version + } + + pub fn get_is_new_create(&self) -> bool { + self.is_new_create + } + + // And more... +} + +pub struct Lock { + interval: i32, + session_id: String, +} + +pub struct Database { + // And more... +} + +impl Database { + pub fn generate_ids(number: usize) -> Vec { + todo!() + } + + pub fn save_records(&mut self) { + todo!() + } + + pub fn delete_records(&mut self) { todo!() } + + pub fn fetch_records(&mut self) { todo!() } + + pub fn get_start_cursor(&mut self) { todo!() } + + pub fn fetch_database_changes(&mut self) { todo!() } + + pub fn get_lock(&mut self) { todo!() } + + pub fn delete_lock(&mut self) { todo!() } + + // And more... +} diff --git a/src/cloud_extension/src/ipc_conn/error.rs b/src/cloud_extension/src/ipc_conn/error.rs index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..8b137891791fe96927ad78e64b0aad7bded08bdc 100644 --- a/src/cloud_extension/src/ipc_conn/error.rs +++ b/src/cloud_extension/src/ipc_conn/error.rs @@ -0,0 +1 @@ + diff --git a/src/cloud_extension/src/ipc_conn/mod.rs b/src/cloud_extension/src/ipc_conn/mod.rs index 8d752fadfcdf4e47c0833944c659a31a64c28830..262d2e78664b192d3b07e26f0b6fdf1f14b72a9b 100644 --- a/src/cloud_extension/src/ipc_conn/mod.rs +++ b/src/cloud_extension/src/ipc_conn/mod.rs @@ -1,2 +1,15 @@ -mod types; -mod error; \ No newline at end of file +// Copyright (c) 2023 Huawei Device Co., Ltd. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +mod connect; +mod error; diff --git a/src/cloud_extension/src/ipc_conn/types.rs b/src/cloud_extension/src/ipc_conn/types.rs deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000