Skip to main content

OutputSplitter

Struct OutputSplitter 

Source
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

Source

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.

Source

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.

Source

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.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.