use crate::ObjectStreamConfig;
#[derive(Debug, Clone, Default)]
pub struct SaveOptions {
pub use_object_streams: bool,
pub use_xref_streams: bool,
pub linearize: bool,
pub object_stream_config: ObjectStreamConfig,
}
impl SaveOptions {
pub fn builder() -> SaveOptionsBuilder {
SaveOptionsBuilder::default()
}
}
#[derive(Default)]
pub struct SaveOptionsBuilder {
use_object_streams: bool,
use_xref_streams: bool,
linearize: bool,
max_objects_per_stream: usize,
compression_level: u32,
}
impl SaveOptionsBuilder {
pub fn use_object_streams(mut self, value: bool) -> Self {
self.use_object_streams = value;
self
}
pub fn use_xref_streams(mut self, value: bool) -> Self {
self.use_xref_streams = value;
self
}
pub fn linearize(mut self, value: bool) -> Self {
self.linearize = value;
self
}
pub fn max_objects_per_stream(mut self, value: usize) -> Self {
self.max_objects_per_stream = value;
self
}
pub fn compression_level(mut self, value: u32) -> Self {
self.compression_level = value;
self
}
pub fn build(self) -> SaveOptions {
SaveOptions {
use_object_streams: self.use_object_streams,
use_xref_streams: self.use_xref_streams,
linearize: self.linearize,
object_stream_config: ObjectStreamConfig {
max_objects_per_stream: if self.max_objects_per_stream == 0 { 100 } else { self.max_objects_per_stream },
compression_level: self.compression_level,
},
}
}
}