precis_tools/generators/
backward_compatible.rs

1use crate::error::Error;
2use crate::generators::CodeGen;
3use std::fs::File;
4use std::io::Write;
5
6/// Generates the [`BackwardCompatible`](https://datatracker.ietf.org/doc/html/rfc8264#section-9.7)
7/// table required by the PRECIS framework.
8pub struct BackwardCompatibleGen {}
9
10impl BackwardCompatibleGen {
11    /// Creates a new table generator for `BackwardCompatible` code points
12    pub fn new() -> Self {
13        Self {}
14    }
15}
16
17impl Default for BackwardCompatibleGen {
18    fn default() -> Self {
19        Self::new()
20    }
21}
22
23impl CodeGen for BackwardCompatibleGen {
24    fn generate_code(&mut self, file: &mut File) -> Result<(), Error> {
25        writeln!(
26            file,
27            "static BACKWARD_COMPATIBLE: [(Codepoints, DerivedPropertyValue); 0] = [",
28        )?;
29        writeln!(file, "];")?;
30        Ok(writeln!(file)?)
31    }
32}