collie_auth/model/
key.rs

1use chrono::{DateTime, FixedOffset};
2use rusqlite::Row;
3use serde::{Deserialize, Serialize};
4
5#[derive(Serialize)]
6pub struct Key {
7    pub id: i32,
8    pub access: String,
9    pub secret: String,
10    pub description: Option<String>,
11    pub expired_at: Option<DateTime<FixedOffset>>,
12}
13
14impl From<&Row<'_>> for Key {
15    fn from(row: &Row) -> Self {
16        Self {
17            id: row.get_unwrap("id"),
18            access: row.get_unwrap("access"),
19            secret: row.get_unwrap("secret"),
20            description: row.get_unwrap("description"),
21            expired_at: row.get_unwrap("expired_at"),
22        }
23    }
24}
25
26#[derive(Deserialize)]
27pub struct KeyToCreate {
28    pub access: String,
29    pub secret: String,
30    pub description: Option<String>,
31    pub expired_at: Option<DateTime<FixedOffset>>,
32}