Implement working database
This commit is contained in:
parent
8427eb082b
commit
4076a4c556
5 changed files with 110 additions and 32 deletions
19
src/word.rs
19
src/word.rs
|
@ -1,11 +1,26 @@
|
|||
use chrono::{DateTime, Utc};
|
||||
use serde::Serialize;
|
||||
use jisho::Entry;
|
||||
use std::convert::From;
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Word {
|
||||
pub id: i64,
|
||||
#[serde(skip_serializing)]
|
||||
pub id: Option<i64>,
|
||||
pub word: String,
|
||||
pub reading: String,
|
||||
pub timestamp: DateTime<Utc>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub timestamp: Option<DateTime<Utc>>,
|
||||
}
|
||||
|
||||
impl From<Entry> for Word {
|
||||
fn from(entry: Entry) -> Self {
|
||||
Self {
|
||||
id: None,
|
||||
word: entry.kanji,
|
||||
reading: entry.reading,
|
||||
timestamp: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue