precis_tools/generators/
codepoints.rs

1use crate::error::Error;
2use crate::generators::CodeGen;
3use std::fs::File;
4use std::io::Write;
5
6/// Generate the `Codepoints` `struct` used by all tables created by all
7/// generators.
8/// # Example:
9/// ```rust
10/// pub enum Codepoints {
11///   Single(u32),
12///   Range(std::ops::RangeInclusive<u32>),
13/// }
14/// ```
15pub struct CodepointsGen {}
16
17impl CodepointsGen {
18    /// Creates a new generator for the `Codepoints` `enum`
19    pub fn new() -> Self {
20        Self {}
21    }
22}
23
24impl Default for CodepointsGen {
25    fn default() -> Self {
26        Self::new()
27    }
28}
29
30impl CodeGen for CodepointsGen {
31    fn generate_code(&mut self, file: &mut File) -> Result<(), Error> {
32        let template = include_str!("codepoints.template");
33        Ok(writeln!(file, "{}", template)?)
34    }
35}