slow5lib 0.1.0

Rust re-implementation of slow5lib: read and write SLOW5/BLOW5 nanopore sequencing files
Documentation
use thiserror::Error;

/// Error type returned by all fallible operations in this crate.
///
/// # Examples
///
/// ```
/// use slow5lib::SlowError;
///
/// let err = SlowError::NotFound("read-001".to_string());
/// assert!(err.to_string().contains("read-001"));
/// ```
#[derive(Debug, Error)]
pub enum SlowError {
    /// Wraps a standard I/O error (file not found, permission denied, etc.).
    #[error("I/O error: {0}")]
    Io(#[from] std::io::Error),

    /// The file contents do not conform to the SLOW5/BLOW5 wire format.
    #[error("invalid format: {0}")]
    InvalidFormat(String),

    /// Decompression of a record or signal failed.
    #[error("decompression failed: {0}")]
    Decompression(String),

    /// A read id was not found in the index or file.
    #[error("read id not found: {0}")]
    NotFound(String),

    /// An index file is missing, corrupt, or incompatible with the data file version.
    #[error("index error: {0}")]
    Index(String),
}

/// Shorthand for `std::result::Result<T, SlowError>`.
///
/// All fallible functions in this crate return this type.
///
/// # Examples
///
/// ```
/// use slow5lib::Result;
///
/// fn always_ok() -> Result<u32> {
///     Ok(42)
/// }
/// assert_eq!(always_ok().unwrap(), 42);
/// ```
pub type Result<T> = std::result::Result<T, SlowError>;