// This file is part of Moonfire NVR, a security camera network video recorder. // Copyright (C) 2021 The Moonfire NVR Authors; see AUTHORS and LICENSE.txt. // SPDX-License-Identifier: GPL-v3.0-or-later WITH GPL-3.0-linking-exception. //! In-memory indexes by calendar day. use crate::recording::{self, Time}; use failure::Error; use log::{error, trace}; use std::cmp; use std::collections::BTreeMap; use std::io::Write; use std::ops::Range; use std::str; /// A calendar day in `YYYY-mm-dd` format. #[derive(Copy, Clone, Debug, Eq, Ord, PartialEq, PartialOrd)] pub struct Key([u8; 10]); impl Key { fn new(tm: time::Tm) -> Result { let mut s = Key([0u8; 10]); write!(&mut s.0[..], "{}", tm.strftime("%Y-%m-%d")?)?; Ok(s) } pub fn bounds(&self) -> Range