pub struct MemoryLimits {
pub max_buffer_size: usize,
pub max_line_length: usize,
pub enable_buffer_pooling: bool,
pub max_pool_size: usize,
}Expand description
Memory limits for buffer management.
Controls maximum buffer sizes, line lengths, and pool configuration to prevent unbounded memory growth and handle memory-constrained environments.
§Examples
§Default Configuration
use hedl_stream::MemoryLimits;
let limits = MemoryLimits::default();
assert_eq!(limits.max_buffer_size, 1024 * 1024);
assert_eq!(limits.max_line_length, 1_000_000);
assert_eq!(limits.enable_buffer_pooling, true);
assert_eq!(limits.max_pool_size, 10);§Memory-Constrained Configuration
use hedl_stream::MemoryLimits;
let limits = MemoryLimits {
max_buffer_size: 64 * 1024, // 64KB max I/O buffer
max_line_length: 100_000, // 100KB max line
enable_buffer_pooling: false, // Disable pooling
max_pool_size: 0,
};§High-Throughput Configuration
use hedl_stream::MemoryLimits;
let limits = MemoryLimits {
max_buffer_size: 2 * 1024 * 1024, // 2MB max I/O buffer
max_line_length: 10_000_000, // 10MB max line
enable_buffer_pooling: true,
max_pool_size: 50, // Large pool
};Fields§
§max_buffer_size: usizeMaximum I/O buffer size in bytes.
Controls the size of the read buffer used by BufReader.
Larger buffers reduce syscall overhead but use more memory.
Default: 1MB
max_line_length: usizeMaximum line length in bytes.
Lines exceeding this length cause a parsing error. This protects against malformed input with extremely long lines.
Default: 1,000,000 bytes (1MB)
enable_buffer_pooling: boolEnable buffer pooling.
When true, reuses string and value buffers across parsing operations. Reduces allocation overhead in high-throughput scenarios.
Default: true
max_pool_size: usizeMaximum number of buffers to pool.
Limits pool growth to prevent unbounded memory usage.
Only effective when enable_buffer_pooling is true.
Default: 10 buffers
Implementations§
Source§impl MemoryLimits
impl MemoryLimits
Sourcepub fn embedded() -> Self
pub fn embedded() -> Self
Configuration for embedded systems or memory-constrained environments.
Uses minimal buffer sizes and disables pooling to minimize memory footprint.
§Examples
use hedl_stream::MemoryLimits;
let limits = MemoryLimits::embedded();
assert_eq!(limits.max_buffer_size, 8 * 1024);
assert_eq!(limits.enable_buffer_pooling, false);Sourcepub fn high_throughput() -> Self
pub fn high_throughput() -> Self
Configuration for large file processing with high throughput.
Uses large buffers and extensive pooling for maximum performance.
§Examples
use hedl_stream::MemoryLimits;
let limits = MemoryLimits::high_throughput();
assert_eq!(limits.max_buffer_size, 2 * 1024 * 1024);
assert_eq!(limits.max_pool_size, 50);Trait Implementations§
Source§impl Clone for MemoryLimits
impl Clone for MemoryLimits
Source§fn clone(&self) -> MemoryLimits
fn clone(&self) -> MemoryLimits
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more