use reovim_driver_codec::{ContentCodec, ContentCodecFactory, ContentType};
use crate::codec::Utf8Codec;
pub struct Utf8CodecFactory;
impl Utf8CodecFactory {
#[must_use]
pub const fn new() -> Self {
Self
}
}
#[cfg_attr(coverage_nightly, coverage(off))]
impl Default for Utf8CodecFactory {
fn default() -> Self {
Self::new()
}
}
impl ContentCodecFactory for Utf8CodecFactory {
fn create(&self, content_type: &ContentType) -> Option<Box<dyn ContentCodec>> {
if content_type.as_str() == ContentType::UTF8 {
Some(Box::new(Utf8Codec::new()))
} else {
None
}
}
fn supported_content_types(&self) -> Vec<&str> {
vec![ContentType::UTF8]
}
fn name(&self) -> &'static str {
"utf-8"
}
}
#[cfg(test)]
#[path = "factory_tests.rs"]
mod tests;