...
This commit is contained in:
parent
0518ddb93d
commit
852347df2b
162
acldb/Cargo.lock
generated
162
acldb/Cargo.lock
generated
@ -24,7 +24,6 @@ dependencies = [
|
||||
"tst",
|
||||
"utoipa",
|
||||
"utoipa-redoc",
|
||||
"utoipa-swagger-ui",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -315,15 +314,6 @@ dependencies = [
|
||||
"windows-sys 0.59.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "arbitrary"
|
||||
version = "1.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dde20b3d026af13f561bdd0f15edf01fc734f0dafcedbaf42bba506a9517f223"
|
||||
dependencies = [
|
||||
"derive_arbitrary",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "async-trait"
|
||||
version = "0.1.88"
|
||||
@ -398,12 +388,6 @@ dependencies = [
|
||||
"alloc-stdlib",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bumpalo"
|
||||
version = "3.17.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1628fb46dfa0b37568d12e5edd512553eccf6a22a78e8bde00bb4aed84d5bdbf"
|
||||
|
||||
[[package]]
|
||||
name = "bytes"
|
||||
version = "1.10.1"
|
||||
@ -471,12 +455,6 @@ dependencies = [
|
||||
"cfg-if",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-utils"
|
||||
version = "0.8.21"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28"
|
||||
|
||||
[[package]]
|
||||
name = "crypto-common"
|
||||
version = "0.1.6"
|
||||
@ -496,17 +474,6 @@ dependencies = [
|
||||
"powerfmt",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "derive_arbitrary"
|
||||
version = "1.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "30542c1ad912e0e3d22a1935c290e12e8a29d704a420177a31faad4a601a0800"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "derive_more"
|
||||
version = "2.0.1"
|
||||
@ -1038,16 +1005,6 @@ version = "0.3.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a"
|
||||
|
||||
[[package]]
|
||||
name = "mime_guess"
|
||||
version = "2.0.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f7c44f8e672c00fe5308fa235f821cb4198414e1c77935c1ab6948d3fd78550e"
|
||||
dependencies = [
|
||||
"mime",
|
||||
"unicase",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "miniz_oxide"
|
||||
version = "0.8.8"
|
||||
@ -1321,40 +1278,6 @@ version = "0.8.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
|
||||
|
||||
[[package]]
|
||||
name = "rust-embed"
|
||||
version = "8.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e5fbc0ee50fcb99af7cebb442e5df7b5b45e9460ffa3f8f549cd26b862bec49d"
|
||||
dependencies = [
|
||||
"rust-embed-impl",
|
||||
"rust-embed-utils",
|
||||
"walkdir",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rust-embed-impl"
|
||||
version = "8.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6bf418c9a2e3f6663ca38b8a7134cc2c2167c9d69688860e8961e3faa731702e"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"rust-embed-utils",
|
||||
"syn",
|
||||
"walkdir",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rust-embed-utils"
|
||||
version = "8.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "08d55b95147fe01265d06b3955db798bdaed52e60e2211c41137701b3aba8e21"
|
||||
dependencies = [
|
||||
"sha2",
|
||||
"walkdir",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustc-demangle"
|
||||
version = "0.1.24"
|
||||
@ -1367,15 +1290,6 @@ version = "1.0.20"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f"
|
||||
|
||||
[[package]]
|
||||
name = "same-file"
|
||||
version = "1.0.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502"
|
||||
dependencies = [
|
||||
"winapi-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "scopeguard"
|
||||
version = "1.2.0"
|
||||
@ -1463,12 +1377,6 @@ dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "simd-adler32"
|
||||
version = "0.3.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d66dc143e6b11c1eddc06d5c423cfc97062865baf299914ab64caa38182078fe"
|
||||
|
||||
[[package]]
|
||||
name = "slab"
|
||||
version = "0.4.9"
|
||||
@ -1691,12 +1599,6 @@ version = "1.18.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1dccffe3ce07af9386bfd29e80c0ab1a8205a2fc34e4bcd40364df902cfa8f3f"
|
||||
|
||||
[[package]]
|
||||
name = "unicase"
|
||||
version = "2.8.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "75b844d17643ee918803943289730bec8aac480150456169e647ed0b576ba539"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.18"
|
||||
@ -1774,40 +1676,12 @@ dependencies = [
|
||||
"utoipa",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "utoipa-swagger-ui"
|
||||
version = "9.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d29519b3c485df6b13f4478ac909a491387e9ef70204487c3b64b53749aec0be"
|
||||
dependencies = [
|
||||
"actix-web",
|
||||
"base64",
|
||||
"mime_guess",
|
||||
"regex",
|
||||
"rust-embed",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"url",
|
||||
"utoipa",
|
||||
"zip",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "version_check"
|
||||
version = "0.9.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"
|
||||
|
||||
[[package]]
|
||||
name = "walkdir"
|
||||
version = "2.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b"
|
||||
dependencies = [
|
||||
"same-file",
|
||||
"winapi-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasi"
|
||||
version = "0.11.0+wasi-snapshot-preview1"
|
||||
@ -1823,15 +1697,6 @@ dependencies = [
|
||||
"wit-bindgen-rt",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi-util"
|
||||
version = "0.1.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb"
|
||||
dependencies = [
|
||||
"windows-sys 0.59.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.52.0"
|
||||
@ -2022,33 +1887,6 @@ dependencies = [
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zip"
|
||||
version = "2.6.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1dcb24d0152526ae49b9b96c1dcf71850ca1e0b882e4e28ed898a93c41334744"
|
||||
dependencies = [
|
||||
"arbitrary",
|
||||
"crc32fast",
|
||||
"crossbeam-utils",
|
||||
"flate2",
|
||||
"indexmap",
|
||||
"memchr",
|
||||
"zopfli",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zopfli"
|
||||
version = "0.8.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "edfc5ee405f504cd4984ecc6f14d02d55cfda60fa4b689434ef4102aae150cd7"
|
||||
dependencies = [
|
||||
"bumpalo",
|
||||
"crc32fast",
|
||||
"log",
|
||||
"simd-adler32",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zstd"
|
||||
version = "0.13.3"
|
||||
|
@ -14,7 +14,6 @@ actix-web = "4"
|
||||
actix-rt = "2"
|
||||
actix-cors = "0.7"
|
||||
utoipa = { version = "5.3.1", features = ["actix_extras"] }
|
||||
utoipa-swagger-ui = { version = "9.0.1", features = ["actix-web"] }
|
||||
utoipa-redoc = { version = "6.0", features = ["actix-web"] }
|
||||
tokio = { version = "1", features = ["full"] }
|
||||
log = "0.4"
|
||||
|
@ -25,7 +25,7 @@ async fn main() -> Result<(), Error> {
|
||||
|
||||
// Create and start server
|
||||
info!("Server listening on {}:{}", config.host, config.port);
|
||||
info!("Swagger UI available at http://{}:{}/swagger", config.host, config.port);
|
||||
info!("API documentation available at http://{}:{}/redoc", config.host, config.port);
|
||||
|
||||
let server = Server::new(config);
|
||||
|
||||
|
@ -5,6 +5,9 @@ use std::collections::HashMap;
|
||||
use utoipa::ToSchema;
|
||||
|
||||
/// RPC request structure
|
||||
///
|
||||
/// This structure represents an RPC request to the ACLDB API.
|
||||
/// It contains the method name, parameters, and a signature for authentication.
|
||||
#[derive(Debug, Clone, Deserialize, ToSchema)]
|
||||
pub struct RpcRequest {
|
||||
/// Method name
|
||||
@ -16,6 +19,9 @@ pub struct RpcRequest {
|
||||
}
|
||||
|
||||
/// RPC response structure
|
||||
///
|
||||
/// This structure represents the response from an RPC request.
|
||||
/// It contains either a result or an error message.
|
||||
#[derive(Debug, Clone, Serialize, ToSchema)]
|
||||
pub struct RpcResponse {
|
||||
/// Result of the operation
|
||||
@ -25,6 +31,9 @@ pub struct RpcResponse {
|
||||
}
|
||||
|
||||
/// ACL update request parameters
|
||||
///
|
||||
/// Parameters for updating or creating an ACL with specified permissions.
|
||||
/// Used with the `acl_update` method.
|
||||
#[derive(Debug, Deserialize, ToSchema)]
|
||||
pub struct AclUpdateParams {
|
||||
/// Public key of the requesting user
|
||||
@ -40,6 +49,9 @@ pub struct AclUpdateParams {
|
||||
}
|
||||
|
||||
/// ACL remove request parameters
|
||||
///
|
||||
/// Parameters for removing specific public keys from an existing ACL.
|
||||
/// Used with the `acl_remove` method.
|
||||
#[derive(Debug, Deserialize, ToSchema)]
|
||||
pub struct AclRemoveParams {
|
||||
/// Public key of the requesting user
|
||||
@ -53,6 +65,9 @@ pub struct AclRemoveParams {
|
||||
}
|
||||
|
||||
/// ACL delete request parameters
|
||||
///
|
||||
/// Parameters for deleting an entire ACL.
|
||||
/// Used with the `acl_del` method.
|
||||
#[derive(Debug, Deserialize, ToSchema)]
|
||||
pub struct AclDelParams {
|
||||
/// Public key of the requesting user
|
||||
@ -64,6 +79,9 @@ pub struct AclDelParams {
|
||||
}
|
||||
|
||||
/// Set request parameters
|
||||
///
|
||||
/// Parameters for storing data with optional ACL protection.
|
||||
/// Used with the `set` method.
|
||||
#[derive(Debug, Deserialize, ToSchema)]
|
||||
pub struct SetParams {
|
||||
/// Public key of the requesting user
|
||||
@ -83,6 +101,9 @@ pub struct SetParams {
|
||||
}
|
||||
|
||||
/// Delete request parameters
|
||||
///
|
||||
/// Parameters for deleting data with ACL verification.
|
||||
/// Used with the `del` method.
|
||||
#[derive(Debug, Deserialize, ToSchema)]
|
||||
pub struct DelParams {
|
||||
/// Public key of the requesting user
|
||||
@ -98,6 +119,9 @@ pub struct DelParams {
|
||||
}
|
||||
|
||||
/// Get request parameters
|
||||
///
|
||||
/// Parameters for retrieving data with ACL verification.
|
||||
/// Used with the `get` method.
|
||||
#[derive(Debug, Deserialize, ToSchema)]
|
||||
pub struct GetParams {
|
||||
/// Public key of the requesting user
|
||||
@ -113,6 +137,9 @@ pub struct GetParams {
|
||||
}
|
||||
|
||||
/// Prefix request parameters
|
||||
///
|
||||
/// Parameters for searching for keys with a specific prefix.
|
||||
/// Used with the `prefix` method.
|
||||
#[derive(Debug, Deserialize, ToSchema)]
|
||||
pub struct PrefixParams {
|
||||
/// Public key of the requesting user
|
||||
|
@ -10,7 +10,6 @@ use serde_json::json;
|
||||
use log::{error, info};
|
||||
use utoipa::OpenApi;
|
||||
use utoipa_redoc::{Redoc, Servable};
|
||||
use utoipa_swagger_ui::SwaggerUi;
|
||||
|
||||
use crate::ACLDB;
|
||||
use crate::rpc::{RpcInterface, RpcRequest, RpcResponse, AclUpdateParams, AclRemoveParams, AclDelParams, SetParams, DelParams, GetParams, PrefixParams};
|
||||
@ -166,7 +165,6 @@ impl Server {
|
||||
|
||||
info!("Starting ACLDB server on {}:{}", self.config.host, self.config.port);
|
||||
info!("API documentation available at: http://{}:{}/redoc", self.config.host, self.config.port);
|
||||
info!("Swagger UI available at: http://{}:{}/swagger", self.config.host, self.config.port);
|
||||
|
||||
// Start the HTTP server
|
||||
HttpServer::new(move || {
|
||||
@ -184,10 +182,6 @@ impl Server {
|
||||
.service(
|
||||
Redoc::with_url("/redoc", serde_json::to_value(ApiDoc::openapi()).unwrap())
|
||||
)
|
||||
.service(
|
||||
SwaggerUi::new("/swagger/{_:.*}")
|
||||
.url("/api-docs/openapi.json", ApiDoc::openapi())
|
||||
)
|
||||
})
|
||||
.bind(format!("{0}:{1}", self.config.host, self.config.port))?
|
||||
.run()
|
||||
@ -266,16 +260,22 @@ fn extract_circle_id(request: &web::Json<RpcRequest>) -> Result<String, Error> {
|
||||
/// API documentation schema
|
||||
#[derive(OpenApi)]
|
||||
#[openapi(
|
||||
paths(
|
||||
handle_rpc,
|
||||
health_check
|
||||
),
|
||||
components(
|
||||
schemas(RpcRequest, RpcResponse)
|
||||
schemas(RpcRequest, RpcResponse, AclUpdateParams, AclRemoveParams, AclDelParams, SetParams, DelParams, GetParams, PrefixParams)
|
||||
),
|
||||
tags(
|
||||
(name = "acldb", description = "ACLDB API - Access Control Database")
|
||||
(name = "acldb", description = "ACLDB API - Access Control Database"),
|
||||
(name = "acl", description = "Access Control List Management"),
|
||||
(name = "data", description = "Data Operations")
|
||||
),
|
||||
info(
|
||||
title = "ACLDB API",
|
||||
version = "1.0.0",
|
||||
description = "API for managing access control lists and data operations in HeroDB",
|
||||
description = "API for managing access control lists and data operations in HeroDB. This API provides functionality for ACL management and data operations with access control.",
|
||||
contact(
|
||||
name = "HeroDB Team",
|
||||
url = "https://ourworld.tf"
|
||||
@ -285,6 +285,29 @@ fn extract_circle_id(request: &web::Json<RpcRequest>) -> Result<String, Error> {
|
||||
struct ApiDoc;
|
||||
|
||||
/// Handler for RPC requests
|
||||
///
|
||||
/// This endpoint handles all RPC requests to the ACLDB API.
|
||||
/// Supported methods include:
|
||||
/// - `acl_update`: Update or create an ACL with specified permissions
|
||||
/// - `acl_remove`: Remove specific public keys from an existing ACL
|
||||
/// - `acl_del`: Delete an entire ACL
|
||||
/// - `set`: Store data with optional ACL protection
|
||||
/// - `get`: Retrieve data with ACL verification
|
||||
/// - `del`: Delete data with ACL verification
|
||||
/// - `prefix`: Search for keys with a specific prefix
|
||||
#[utoipa::path(
|
||||
post,
|
||||
path = "/rpc",
|
||||
request_body = RpcRequest,
|
||||
responses(
|
||||
(status = 200, description = "RPC request processed successfully", body = RpcResponse),
|
||||
(status = 400, description = "Invalid request parameters", body = RpcResponse),
|
||||
(status = 401, description = "Permission denied", body = RpcResponse),
|
||||
(status = 404, description = "Resource not found", body = RpcResponse),
|
||||
(status = 500, description = "Server error", body = RpcResponse)
|
||||
),
|
||||
tag = "acldb"
|
||||
)]
|
||||
async fn handle_rpc(
|
||||
server: web::Data<Server>,
|
||||
request: web::Json<RpcRequest>,
|
||||
@ -475,6 +498,16 @@ async fn process_request(
|
||||
}
|
||||
|
||||
/// Handler for health check
|
||||
///
|
||||
/// This endpoint provides a simple health check to verify the server is running.
|
||||
#[utoipa::path(
|
||||
get,
|
||||
path = "/health",
|
||||
responses(
|
||||
(status = 200, description = "Server is healthy", body = String)
|
||||
),
|
||||
tag = "acldb"
|
||||
)]
|
||||
async fn health_check() -> impl Responder {
|
||||
HttpResponse::Ok().json(json!({"status": "ok"}))
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
use crate::db::error::{DbError, DbResult};
|
||||
use crate::db::model::{Model, Storable};
|
||||
use crate::db::model::Model;
|
||||
use crate::db::store::{DbOperations, OurDbStore};
|
||||
use std::any::TypeId;
|
||||
use std::collections::HashMap;
|
||||
|
@ -1,5 +1,5 @@
|
||||
use crate::db::error::{DbError, DbResult};
|
||||
use crate::db::model::Model;
|
||||
use crate::db::model::{Model, Storable};
|
||||
use ourdb::{OurDB, OurDBConfig, OurDBSetArgs};
|
||||
use std::marker::PhantomData;
|
||||
use std::path::{Path, PathBuf};
|
||||
@ -51,8 +51,8 @@ impl<T: Model> OurDbStore<T> {
|
||||
/// Inserts or updates a model instance in the database
|
||||
pub fn insert(&mut self, model: &T) -> DbResult<()> {
|
||||
let id = model.get_id();
|
||||
// Use the new method name from the Storable trait
|
||||
let data = T::to_bytes(model)?;
|
||||
// Use the new method name
|
||||
let data = model.to_bytes()?;
|
||||
|
||||
self.db.set(OurDBSetArgs {
|
||||
id: Some(id),
|
||||
@ -71,7 +71,7 @@ impl<T: Model> OurDbStore<T> {
|
||||
}
|
||||
})?;
|
||||
|
||||
// Use the new method name from the Storable trait
|
||||
// Use the new method name
|
||||
T::from_bytes(&data)
|
||||
}
|
||||
|
||||
@ -112,13 +112,13 @@ impl<T: Model> OurDbStore<T> {
|
||||
}
|
||||
|
||||
impl<T: Model> DbOperations for OurDbStore<T> {
|
||||
fn delete(&self, id: u32) -> DbResult<()> {
|
||||
fn delete(&self, _id: u32) -> DbResult<()> {
|
||||
// We need to mutably borrow self, but the trait requires &self
|
||||
// This is a design issue that needs to be fixed at the trait level
|
||||
Err(DbError::GeneralError("DbOperations trait needs to be updated to use &mut self".to_string()))
|
||||
}
|
||||
|
||||
fn get(&self, id: u32) -> DbResult<Box<dyn Any>> {
|
||||
fn get(&self, _id: u32) -> DbResult<Box<dyn Any>> {
|
||||
// We need to mutably borrow self, but the trait requires &self
|
||||
// This is a design issue that needs to be fixed at the trait level
|
||||
Err(DbError::GeneralError("DbOperations trait needs to be updated to use &mut self".to_string()))
|
||||
@ -130,19 +130,19 @@ impl<T: Model> DbOperations for OurDbStore<T> {
|
||||
Ok(Box::new(result))
|
||||
}
|
||||
|
||||
fn insert(&self, model: &dyn Any) -> DbResult<()> {
|
||||
fn insert(&self, _model: &dyn Any) -> DbResult<()> {
|
||||
// We need to mutably borrow self, but the trait requires &self
|
||||
// This is a design issue that needs to be fixed at the trait level
|
||||
Err(DbError::GeneralError("DbOperations trait needs to be updated to use &mut self".to_string()))
|
||||
}
|
||||
|
||||
fn insert_raw(&self, serialized: &[u8]) -> DbResult<()> {
|
||||
fn insert_raw(&self, _serialized: &[u8]) -> DbResult<()> {
|
||||
// We need to mutably borrow self, but the trait requires &self
|
||||
// This is a design issue that needs to be fixed at the trait level
|
||||
Err(DbError::GeneralError("DbOperations trait needs to be updated to use &mut self".to_string()))
|
||||
}
|
||||
|
||||
fn get_history(&self, id: u32, depth: u8) -> DbResult<Vec<Box<dyn Any>>> {
|
||||
fn get_history(&self, _id: u32, _depth: u8) -> DbResult<Vec<Box<dyn Any>>> {
|
||||
// We need to mutably borrow self, but the trait requires &self
|
||||
// This is a design issue that needs to be fixed at the trait level
|
||||
Err(DbError::GeneralError("DbOperations trait needs to be updated to use &mut self".to_string()))
|
||||
|
@ -132,23 +132,9 @@ impl Committee {
|
||||
|
||||
// Implement Storable trait
|
||||
impl Storable for Committee {
|
||||
fn to_bytes(&self) -> DbResult<Vec<u8>> {
|
||||
bincode::serialize(self).map_err(DbError::SerializationError)
|
||||
}
|
||||
|
||||
fn from_bytes(data: &[u8]) -> DbResult<Self> {
|
||||
bincode::deserialize(data).map_err(DbError::SerializationError)
|
||||
}
|
||||
}
|
||||
|
||||
impl Storable for CommitteeMember {
|
||||
fn to_bytes(&self) -> DbResult<Vec<u8>> {
|
||||
bincode::serialize(self).map_err(DbError::SerializationError)
|
||||
}
|
||||
|
||||
fn from_bytes(data: &[u8]) -> DbResult<Self> {
|
||||
bincode::deserialize(data).map_err(DbError::SerializationError)
|
||||
}
|
||||
}
|
||||
|
||||
// Implement Model trait
|
||||
|
Loading…
Reference in New Issue
Block a user