use super::RuntimeConfig;
use alloc::sync::Arc;
#[derive(Default)]
#[must_use = "dropping the pin before the files are installed lets a collection take their dictionary"]
pub struct WritePin {
snapshot: Option<Arc<RuntimeConfig>>,
filter_sizing: Option<crate::filter_budget::FilterPlan>,
}
impl WritePin {
#[cfg(zstd_any)]
pub(crate) fn new(snapshot: &Arc<RuntimeConfig>) -> Self {
Self {
snapshot: snapshot
.write_dict_ids(true)
.next()
.map(|_| Arc::clone(snapshot)),
filter_sizing: None,
}
}
#[cfg(not(zstd_any))]
pub(crate) fn new(_snapshot: &Arc<RuntimeConfig>) -> Self {
Self::default()
}
pub(crate) fn with_filter_sizing(
mut self,
sizing: Option<crate::filter_budget::FilterPlan>,
) -> Self {
self.filter_sizing = sizing;
self
}
}
impl core::fmt::Debug for WritePin {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
f.debug_struct("WritePin")
.field("holds", &self.snapshot.is_some())
.field("filter_budget", &self.filter_sizing.is_some())
.finish()
}
}