dw_models/
key_value.rs

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