pub struct OutputSplitter { /* private fields */ }Expand description
Manages splitting output across multiple files following a two-letter directory/file naming convention.
Files are organized into directories named with two uppercase letters
(AA, AB, …, AZ, BA, …, ZZ) with up to 100 files per directory
(wiki_00 through wiki_99). When a file exceeds the configured size
limit, it is closed and a new file is opened.
Implementations§
Source§impl OutputSplitter
impl OutputSplitter
Sourcepub fn new(config: OutputConfig) -> Result<Self, Error>
pub fn new(config: OutputConfig) -> Result<Self, Error>
Creates a new OutputSplitter with the given configuration.
If the path is "-", output is written to stdout without file
splitting. Otherwise, the first output file is opened immediately.
§Arguments
config- The output configuration specifying path, file size limit, and compression settings.
§Returns
A new OutputSplitter ready to accept writes, or an Error if the
initial output file cannot be created.
Sourcepub fn write(&mut self, data: &str) -> Result<(), Error>
pub fn write(&mut self, data: &str) -> Result<(), Error>
Writes formatted page data to the current output.
For file-based output, this method automatically handles rotation when
the current file exceeds the configured max_file_size, or after every
article when max_file_size is 0.
For stdout mode, data is written directly without splitting.
§Arguments
data- The article text to write.
§Returns
Ok(()) on success, or an Error if writing or file rotation fails.
Sourcepub fn close(&mut self) -> Result<(), Error>
pub fn close(&mut self) -> Result<(), Error>
Closes the current output file, flushing buffers and finishing compression if applicable.
For stdout mode this is a no-op. For file-based output, the current writer is dropped after flushing.
§Returns
Ok(()) on success, or an Error if flushing or finishing compression
fails.