java-diff-utils-rs 0.1.0-alpha.5

Experimental Rust port of the core diffing and patching behavior of java-diff-utils
Documentation
use std::error::Error;
use std::fmt;

/// Equivalent to Java's `UnifiedDiffParserException`.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct UnifiedDiffParserException {
    pub message: String,
}

impl UnifiedDiffParserException {
    pub fn new<S: Into<String>>(message: S) -> Self {
        Self {
            message: message.into(),
        }
    }
}

impl fmt::Display for UnifiedDiffParserException {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        write!(f, "UnifiedDiffParserException: {}", self.message)
    }
}

impl Error for UnifiedDiffParserException {}

// Allows automatically converting standard IO errors into this parser exception
impl From<std::io::Error> for UnifiedDiffParserException {
    fn from(err: std::io::Error) -> Self {
        UnifiedDiffParserException::new(err.to_string())
    }
}