1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
//! Memory management utilities for ruvector-core
//!
//! This module provides memory-efficient data structures and utilities
//! for vector storage operations.
/// Memory pool for vector allocations.
#[derive(Debug, Default)]
pub struct MemoryPool {
/// Total allocated bytes.
allocated: usize,
/// Maximum allocation limit.
limit: Option<usize>,
}
impl MemoryPool {
/// Create a new memory pool.
pub fn new() -> Self {
Self::default()
}
/// Create a memory pool with a limit.
pub fn with_limit(limit: usize) -> Self {
Self {
allocated: 0,
limit: Some(limit),
}
}
/// Get currently allocated bytes.
pub fn allocated(&self) -> usize {
self.allocated
}
/// Get the allocation limit, if any.
pub fn limit(&self) -> Option<usize> {
self.limit
}
}