use chgk_ledb_lib

This commit is contained in:
Dmitry Belyaev 2022-11-11 20:56:35 +03:00
parent 1eadfac11a
commit 747a611a67
Signed by: b4tman
GPG Key ID: 41A00BF15EA7E5F3
3 changed files with 486 additions and 188 deletions

586
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -12,12 +12,10 @@ readme = "README.md"
[dependencies] [dependencies]
rand="0.8" rand="0.8"
serde="1.0" serde="1.0"
serde_derive="1.0"
serde_json="1.0" serde_json="1.0"
ledb="0.4" ledb = {git = "https://github.com/b4tman/ledb.git", rev="a646b90e", package="ledb"}
ledb-derive="0.4"
ledb-types="0.4"
rocket="0.4" rocket="0.4"
chgk_ledb_lib = {git = "https://gitea.b4tman.ru/b4tman/chgk_ledb.git", rev="e521e39f5e", package="chgk_ledb_lib"}
# lmdb-zero="0.4" # lmdb-zero="0.4"

View File

@ -1,13 +1,8 @@
#![feature(proc_macro_hygiene, decl_macro)] #![feature(proc_macro_hygiene, decl_macro)]
extern crate serde;
#[macro_use]
extern crate serde_derive;
extern crate ledb; extern crate ledb;
extern crate serde;
extern crate serde_json; extern crate serde_json;
#[macro_use]
extern crate ledb_derive;
extern crate ledb_types;
#[macro_use] #[macro_use]
extern crate rocket; extern crate rocket;
@ -23,6 +18,8 @@ use rand::Rng;
use ledb::{Options, Storage}; use ledb::{Options, Storage};
use chgk_ledb_lib::questions::Question;
trait ErrorEmpty { trait ErrorEmpty {
type Output; type Output;
fn err_empty(self) -> Result<Self::Output, ()>; fn err_empty(self) -> Result<Self::Output, ()>;
@ -35,79 +32,6 @@ impl<T, E> ErrorEmpty for Result<T, E> {
} }
} }
#[derive(Debug, Default, Clone, Serialize, Deserialize, Document)]
struct BatchInfo {
#[document(primary)]
#[serde(default)]
filename: String,
#[serde(default)]
description: String,
#[serde(default)]
author: String,
#[serde(default)]
comment: String,
#[serde(default)]
url: String,
#[serde(default)]
date: String,
#[serde(default)]
processed_by: String,
#[serde(default)]
redacted_by: String,
#[serde(default)]
copyright: String,
#[serde(default)]
theme: String,
#[serde(default)]
kind: String,
#[serde(default)]
source: String,
#[serde(default)]
rating: String,
}
#[derive(Debug, Default, Clone, Serialize, Deserialize, Document)]
struct Question {
#[document(primary)]
#[serde(default)]
num: u32,
#[document(index)]
id: String,
description: String,
answer: String,
#[serde(default)]
author: String,
#[serde(default)]
comment: String,
#[serde(default)]
comment1: String,
#[serde(default)]
tour: String,
#[serde(default)]
url: String,
#[serde(default)]
date: String,
#[serde(default)]
processed_by: String,
#[serde(default)]
redacted_by: String,
#[serde(default)]
copyright: String,
#[serde(default)]
theme: String,
#[serde(default)]
kind: String,
#[serde(default)]
source: String,
#[serde(default)]
rating: String,
#[document(nested)]
#[serde(default)]
batch_info: BatchInfo,
}
struct AppState { struct AppState {
storage: Storage, storage: Storage,
database_distribution: Uniform<u32>, database_distribution: Uniform<u32>,