use reovim_driver_codec::{ContentClassifier, ContentType};
pub struct Utf8Classifier;
impl Utf8Classifier {
#[must_use]
pub const fn new() -> Self {
Self
}
}
#[cfg_attr(coverage_nightly, coverage(off))]
impl Default for Utf8Classifier {
fn default() -> Self {
Self::new()
}
}
impl ContentClassifier for Utf8Classifier {
fn classify(&self, raw: &[u8], _path: &str) -> Option<ContentType> {
if std::str::from_utf8(raw).is_ok() {
Some(ContentType::new(ContentType::UTF8))
} else {
None
}
}
fn priority(&self) -> u8 {
10
}
fn name(&self) -> &'static str {
"utf-8"
}
}
#[cfg(test)]
#[path = "classifier_tests.rs"]
mod tests;