Skip to main content

uncomment/
lib.rs

1pub mod ast;
2pub mod cli;
3pub mod config;
4pub mod languages;
5pub mod processor;
6pub mod rules;
7
8pub use processor::{ProcessingOptions, Processor};
9pub use rules::preservation::PreservationRule;
10
11use std::error::Error;
12use std::fmt;
13
14#[derive(Debug)]
15pub enum UncommentError {
16    Io(std::io::Error),
17    ParseError(String),
18    LanguageNotSupported(String),
19    TreeSitterError(String),
20}
21
22impl fmt::Display for UncommentError {
23    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
24        match self {
25            UncommentError::Io(err) => write!(f, "IO error: {err}"),
26            UncommentError::ParseError(msg) => write!(f, "Parse error: {msg}"),
27            UncommentError::LanguageNotSupported(lang) => {
28                write!(f, "Language not supported: {lang}")
29            }
30            UncommentError::TreeSitterError(msg) => write!(f, "Tree-sitter error: {msg}"),
31        }
32    }
33}
34
35impl Error for UncommentError {}
36
37impl From<std::io::Error> for UncommentError {
38    fn from(err: std::io::Error) -> Self {
39        UncommentError::Io(err)
40    }
41}
42
43pub type Result<T> = std::result::Result<T, UncommentError>;