use chgk_ledb_lib
This commit is contained in:
parent
1eadfac11a
commit
747a611a67
586
Cargo.lock
generated
586
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -12,12 +12,10 @@ readme = "README.md"
|
||||
[dependencies]
|
||||
rand="0.8"
|
||||
serde="1.0"
|
||||
serde_derive="1.0"
|
||||
serde_json="1.0"
|
||||
ledb="0.4"
|
||||
ledb-derive="0.4"
|
||||
ledb-types="0.4"
|
||||
ledb = {git = "https://github.com/b4tman/ledb.git", rev="a646b90e", package="ledb"}
|
||||
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"
|
||||
|
||||
|
82
src/main.rs
82
src/main.rs
@ -1,13 +1,8 @@
|
||||
#![feature(proc_macro_hygiene, decl_macro)]
|
||||
|
||||
extern crate serde;
|
||||
#[macro_use]
|
||||
extern crate serde_derive;
|
||||
extern crate ledb;
|
||||
extern crate serde;
|
||||
extern crate serde_json;
|
||||
#[macro_use]
|
||||
extern crate ledb_derive;
|
||||
extern crate ledb_types;
|
||||
|
||||
#[macro_use]
|
||||
extern crate rocket;
|
||||
@ -23,6 +18,8 @@ use rand::Rng;
|
||||
|
||||
use ledb::{Options, Storage};
|
||||
|
||||
use chgk_ledb_lib::questions::Question;
|
||||
|
||||
trait ErrorEmpty {
|
||||
type 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 {
|
||||
storage: Storage,
|
||||
database_distribution: Uniform<u32>,
|
||||
|
Loading…
Reference in New Issue
Block a user