1mod fixed;
3
4use crate::types::*;
5use anyhow::Result;
6
7pub fn fmt_message(mes: &mut Vec<Message>, opt: FormatOptions, typ: ScriptType) -> Result<()> {
9 match opt {
10 FormatOptions::Fixed {
11 length,
12 keep_original,
13 break_words,
14 insert_fullwidth_space_at_line_start,
15 break_with_sentence,
16 #[cfg(feature = "jieba")]
17 break_chinese_words,
18 #[cfg(feature = "jieba")]
19 jieba_dict,
20 } => {
21 let formatter = fixed::FixedFormatter::new(
22 length,
23 keep_original,
24 break_words,
25 insert_fullwidth_space_at_line_start,
26 break_with_sentence,
27 #[cfg(feature = "jieba")]
28 break_chinese_words,
29 #[cfg(feature = "jieba")]
30 jieba_dict,
31 Some(typ),
32 )?;
33 for message in mes.iter_mut() {
34 message.message = formatter.format(&message.message);
35 }
36 }
37 FormatOptions::None => {}
38 }
39 Ok(())
40}