From 60c9d1037f012e76cf8f8c11d82b065b1f97269f Mon Sep 17 00:00:00 2001 From: Jan Tuomi Date: Sat, 11 Jan 2025 23:16:06 +0200 Subject: Add range_by, refactor reading from file --- log_db/src/common.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'log_db/src/common.rs') 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 { + start: Bound, + end: Bound, +} + +impl OwnedBounds { + pub fn new(start: Bound, end: Bound) -> Self { + OwnedBounds { start, end } + } +} + +impl RangeBounds for OwnedBounds { + fn start_bound(&self) -> Bound<&T> { + self.start.as_ref() + } + + fn end_bound(&self) -> Bound<&T> { + self.end.as_ref() + } +} -- cgit v1.3