pub struct RotatingWriter { /* private fields */ }Expand description
Wraps a daily {YYYY-MM-DD}.bin file with automatic rotation at UTC midnight.
Implementations§
Source§impl RotatingWriter
impl RotatingWriter
Sourcepub fn new(dir: impl Into<PathBuf>) -> Result<Self>
pub fn new(dir: impl Into<PathBuf>) -> Result<Self>
Open (or create) today’s daily file under dir.
Sourcepub fn append(&mut self, ts_ms: i64, payload: &[u8]) -> Result<()>
pub fn append(&mut self, ts_ms: i64, payload: &[u8]) -> Result<()>
Append one record. Rotates to a new file if UTC date has advanced.
Sourcepub fn rotate_to(&mut self, day: NaiveDate) -> Result<()>
pub fn rotate_to(&mut self, day: NaiveDate) -> Result<()>
Force rotate to a specific date. Used in tests to simulate midnight crossing.
Sourcepub fn current_day(&self) -> NaiveDate
pub fn current_day(&self) -> NaiveDate
Return the current day this writer is writing to.
Auto Trait Implementations§
impl Freeze for RotatingWriter
impl RefUnwindSafe for RotatingWriter
impl Send for RotatingWriter
impl Sync for RotatingWriter
impl Unpin for RotatingWriter
impl UnsafeUnpin for RotatingWriter
impl UnwindSafe for RotatingWriter
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more