SolarEnergy/central_backend/src/energy/relay_state_history.rs

45 lines
1.1 KiB
Rust
Raw Normal View History

2024-09-16 20:41:20 +00:00
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!()
}
}