reovim_module_codec_utf8/
factory.rs1use reovim_driver_codec::{ContentCodec, ContentCodecFactory, ContentType};
4
5use crate::codec::Utf8Codec;
6
7pub struct Utf8CodecFactory;
11
12impl Utf8CodecFactory {
13 #[must_use]
15 pub const fn new() -> Self {
16 Self
17 }
18}
19
20#[cfg_attr(coverage_nightly, coverage(off))]
21impl Default for Utf8CodecFactory {
22 fn default() -> Self {
23 Self::new()
24 }
25}
26
27impl ContentCodecFactory for Utf8CodecFactory {
28 fn create(&self, content_type: &ContentType) -> Option<Box<dyn ContentCodec>> {
29 if content_type.as_str() == ContentType::UTF8 {
30 Some(Box::new(Utf8Codec::new()))
31 } else {
32 None
33 }
34 }
35
36 fn supported_content_types(&self) -> Vec<&str> {
37 vec![ContentType::UTF8]
38 }
39
40 fn name(&self) -> &'static str {
41 "utf-8"
42 }
43}
44
45#[cfg(test)]
46#[path = "factory_tests.rs"]
47mod tests;