use super::{ParallelCompressor, ParallelConfig, ParallelConfigError, core};
use crate::graph::CompressorGraph;
use crate::{Backend, EncoderConfig};
#[derive(Clone, Debug)]
pub struct ParallelCompressorBuilder {
pub(super) encoder: EncoderConfig,
pub(super) parallel: ParallelConfig,
pub(super) backend: Option<Backend>,
pub(super) graph: Option<CompressorGraph>,
}
impl ParallelCompressorBuilder {
#[must_use]
pub fn with_graph(mut self, graph: CompressorGraph) -> Self {
self.graph = Some(graph);
self
}
#[must_use]
pub const fn with_backend(mut self, backend: Backend) -> Self {
self.backend = Some(backend);
self
}
pub fn build(self) -> Result<ParallelCompressor, ParallelConfigError> {
let mut inner = core::Compressor::new(
self.encoder,
self.parallel,
self.backend.unwrap_or_default(),
)?;
inner.graph = self.graph;
Ok(ParallelCompressor { inner })
}
}