aw_models/
key_value.rs

1use chrono::{DateTime, Utc};
2use schemars::JsonSchema;
3use serde::{Deserialize, Serialize};
4
5#[derive(Serialize, Deserialize, JsonSchema)]
6pub struct Key {
7    pub key: String,
8}
9
10#[derive(Serialize, Deserialize, JsonSchema, Clone, Debug, PartialEq)]
11pub struct KeyValue {
12    pub key: String,
13    pub value: String,
14    pub timestamp: Option<DateTime<Utc>>,
15}
16
17impl KeyValue {
18    pub fn new<T: Into<String>>(key: T, value: T, timestamp: DateTime<Utc>) -> KeyValue {
19        KeyValue {
20            key: key.into(),
21            value: value.into(),
22            timestamp: Some(timestamp),
23        }
24    }
25}