//! Shared options for the conversion APIs. use std::path::PathBuf; use crate::mst::BuilderOptions; use crate::storage::StorageOptions; /// Tunables for the streaming conversion. `Default` is sensible for most /// repos; tweak for very-large repos or constrained-memory environments. #[derive(Debug, Clone, Default)] pub struct ConvertOptions { pub mst: BuilderOptions, pub storage: StorageOptions, } impl ConvertOptions { pub fn with_spill_threshold(mut self, threshold: u64) -> Self { self.storage.spill_threshold = threshold; self } /// Disable disk spilling — equivalent to /// [`Self::with_spill_threshold`]`(u64::MAX)`. The entire CAR body /// stays in memory; peak RAM ≈ full CAR size. /// /// Intended for benchmarks and tests where you want to isolate /// in-memory behavior. **Not recommended for production async use:** /// in highly-concurrent environments (many simultaneous repo /// conversions), the bound-on-peak-memory that disk spilling provides /// is the whole point. Prefer the default threshold + a /// `spawn_blocking` bridge (see the `async_bridge` example). pub fn no_spill(mut self) -> Self { self.storage.spill_threshold = u64::MAX; self } pub fn with_tempdir(mut self, dir: PathBuf) -> Self { self.storage.tempdir = Some(dir); self } pub fn with_max_entries_per_node(mut self, n: usize) -> Self { self.mst.max_entries_per_node = n; self } }