diff options
| author | Jan Tuomi <jan@jantuomi.fi> | 2025-01-11 23:16:06 +0200 |
|---|---|---|
| committer | Jan Tuomi <jan@jantuomi.fi> | 2025-01-11 23:40:20 +0200 |
| commit | 60c9d1037f012e76cf8f8c11d82b065b1f97269f (patch) | |
| tree | a050c7ecb46bdbdf9dfd7bdeb15b9c5f84e70b24 /log_db/src/common.rs | |
| parent | 899927cf6e517690622cb6cab40d15f19bd229cb (diff) | |
Add range_by, refactor reading from file
Diffstat (limited to 'log_db/src/common.rs')
| -rw-r--r-- | log_db/src/common.rs | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/log_db/src/common.rs b/log_db/src/common.rs index 1841175..48c85ea 100644 --- a/log_db/src/common.rs +++ b/log_db/src/common.rs @@ -5,6 +5,7 @@ use std::collections::HashSet; use std::fmt::Display; use std::fs::{self, metadata, File}; use std::io::{self, Read, Seek, SeekFrom, Write}; +use std::ops::{Bound, RangeBounds}; use std::path::{Path, PathBuf}; use std::thread; use thiserror::Error; @@ -768,3 +769,24 @@ pub fn request_exclusive_lock(data_dir: &Path, file: &mut fs::File) -> Result<() Ok(()) } + +pub struct OwnedBounds<T> { + start: Bound<T>, + end: Bound<T>, +} + +impl<T> OwnedBounds<T> { + pub fn new(start: Bound<T>, end: Bound<T>) -> Self { + OwnedBounds { start, end } + } +} + +impl<T> RangeBounds<T> for OwnedBounds<T> { + fn start_bound(&self) -> Bound<&T> { + self.start.as_ref() + } + + fn end_bound(&self) -> Bound<&T> { + self.end.as_ref() + } +} |
