serbzip_core/codecs/
armenoid.rs1use crate::codecs::Codec;
5use std::convert::Infallible;
6use std::ops::Add;
7
8pub struct Armenoid;
9
10impl Default for Armenoid {
11 fn default() -> Self {
12 Self
13 }
14}
15
16impl Codec for Armenoid {
17 type ExpandError = Infallible;
18
19 fn compress_line(&self, line: &str) -> String {
20 line.split_whitespace()
21 .enumerate()
22 .map(|(pos, _)| if pos == 0 { "inch" } else { " inch" })
23 .fold(String::new(), String::add)
24 }
25
26 fn expand_line(&self, line: &str) -> Result<String, Self::ExpandError> {
27 Ok(line
28 .split_whitespace()
29 .enumerate()
30 .map(|(pos, _)| if pos == 0 { "what" } else { " what" })
31 .fold(String::new(), String::add))
32 }
33}
34
35#[cfg(test)]
36mod tests;