SegmentManager

Struct SegmentManager 

Source
pub struct SegmentManager { /* private fields */ }
Expand description

Manages WAL segment files

Implementations§

Source§

impl SegmentManager

Source

pub fn new(wal_dir: PathBuf) -> Self

Create a new segment manager for the given WAL directory

Source

pub fn list_segments(&self) -> Result<Vec<SegmentInfo>>

List all segment files in order

Source

pub fn total_size(&self) -> Result<u64>

Get the total size of all segments

Source

pub fn segment_count(&self) -> Result<usize>

Get the number of segment files

Source

pub fn cleanup_before(&self, sequence: u64) -> Result<usize>

Delete segments older than the given sequence number

This is useful after a checkpoint to reclaim disk space. Returns the number of segments deleted.

Source

pub fn cleanup_all(&self) -> Result<usize>

Delete all segment files

Use with caution - this removes all WAL data!

Source

pub fn latest_segment(&self) -> Result<Option<SegmentInfo>>

Get the latest (highest sequence) segment

Source

pub fn oldest_segment(&self) -> Result<Option<SegmentInfo>>

Get the oldest (lowest sequence) segment

Source

pub fn is_available(&self) -> bool

Check if the WAL directory exists and is accessible

Source

pub fn ensure_dir(&self) -> Result<()>

Create the WAL directory if it doesn’t exist

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.