45 lines
1.1 KiB
Rust
45 lines
1.1 KiB
Rust
|
use crate::devices::device::DeviceRelayID;
|
||
|
|
||
|
/// # RelayStateHistory
|
||
|
///
|
||
|
/// This structures handles the manipulation of relay state history files
|
||
|
///
|
||
|
/// These file are binary file optimizing used space.
|
||
|
pub struct RelayStateHistory {
|
||
|
id: DeviceRelayID,
|
||
|
day: usize,
|
||
|
buff: Vec<u8>,
|
||
|
}
|
||
|
|
||
|
impl RelayStateHistory {
|
||
|
/// Open relay state history file, if it exist, or create an empty one
|
||
|
pub fn open(id: DeviceRelayID, day: usize) -> anyhow::Result<Self> {
|
||
|
todo!()
|
||
|
}
|
||
|
|
||
|
/// Create a new in memory dev relay state history
|
||
|
fn new_memory(id: DeviceRelayID, day: usize) -> Self {
|
||
|
todo!()
|
||
|
}
|
||
|
|
||
|
/// Resolve time offset of a given time in buffer
|
||
|
fn resolve_offset(&self, time: i64) -> anyhow::Result<(usize, u8)> {
|
||
|
todo!()
|
||
|
}
|
||
|
|
||
|
/// Set new state of relay
|
||
|
fn set_state(&mut self, time: i64, on: bool) -> anyhow::Result<()> {
|
||
|
todo!()
|
||
|
}
|
||
|
|
||
|
/// Get the state of relay at a given time
|
||
|
fn get_state(&self, time: i64) -> anyhow::Result<bool> {
|
||
|
todo!()
|
||
|
}
|
||
|
|
||
|
/// Persist device relay state history
|
||
|
pub fn save(&self) -> anyhow::Result<()> {
|
||
|
todo!()
|
||
|
}
|
||
|
}
|