mod channel;
pub mod key;
mod merge;
mod run;
mod sorter;
#[cfg(feature = "python")]
mod python;
use std::fmt;
use std::io;
pub use merge::Merged;
pub use sorter::{
Config, DEFAULT_MAX_BYTES, DEFAULT_MAX_OPEN, DEFAULT_THREADS, MIN_MAX_BYTES, MIN_MAX_OPEN,
Sorter,
};
#[cfg(doctest)]
#[doc = include_str!("../README.md")]
struct ReadmeDoctests;
#[derive(Debug)]
#[non_exhaustive]
pub enum Error {
Io(io::Error),
Invalid(String),
Failed,
}
impl From<io::Error> for Error {
fn from(error: io::Error) -> Self {
Error::Io(error)
}
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Error::Io(error) => error.fmt(f),
Error::Invalid(message) => f.write_str(message),
Error::Failed => f.write_str("an earlier error lost records, so sorting cannot go on"),
}
}
}
impl std::error::Error for Error {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
match self {
Error::Io(error) => Some(error),
Error::Invalid(_) | Error::Failed => None,
}
}
}
pub type Result<T> = std::result::Result<T, Error>;