add pattern sort fields.
This commit is contained in:
parent
db5b7f1dec
commit
a1b5859cd6
|
@ -36,6 +36,8 @@ rand = "0.8.5"
|
|||
tauri-plugin-devtools = "2.0.0"
|
||||
tauri-plugin-os = "2"
|
||||
tauri-plugin-notification = "2"
|
||||
chrono = { version = "0.4.40", features = ["serde"] }
|
||||
tzfile = "0.1.3"
|
||||
|
||||
[target.'cfg(not(any(target_os = "android", target_os = "ios")))'.dependencies]
|
||||
tauri-plugin-single-instance = "2"
|
||||
|
|
|
@ -4,15 +4,24 @@ mod pulse;
|
|||
|
||||
use std::collections::VecDeque;
|
||||
|
||||
use chrono::{
|
||||
naive::serde::{ts_milliseconds, ts_milliseconds_option},
|
||||
NaiveDateTime,
|
||||
};
|
||||
pub use pulse::Pulse;
|
||||
use pulse::{generate_pulse_sequence, RawPulse};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use sled::IVec;
|
||||
use uuid::Uuid;
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct Pattern {
|
||||
pub id: Uuid,
|
||||
pub name: String,
|
||||
#[serde(with = "ts_milliseconds")]
|
||||
pub created_at: NaiveDateTime,
|
||||
#[serde(with = "ts_milliseconds_option")]
|
||||
pub last_modified_at: Option<NaiveDateTime>,
|
||||
pub smooth_repeat: bool,
|
||||
pub pulses: VecDeque<Pulse>,
|
||||
}
|
||||
|
@ -64,3 +73,27 @@ impl Pattern {
|
|||
duration
|
||||
}
|
||||
}
|
||||
|
||||
impl From<&[u8]> for Pattern {
|
||||
fn from(bytes: &[u8]) -> Self {
|
||||
bincode::deserialize(&bytes).unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
impl From<IVec> for Pattern {
|
||||
fn from(bytes: IVec) -> Self {
|
||||
bincode::deserialize(&bytes).unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
impl Into<IVec> for Pattern {
|
||||
fn into(self) -> IVec {
|
||||
bincode::serialize(&self).unwrap().into()
|
||||
}
|
||||
}
|
||||
|
||||
impl Into<IVec> for &Pattern {
|
||||
fn into(self) -> IVec {
|
||||
bincode::serialize(self).unwrap().into()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user