tinymist_world/
config.rs

1use std::borrow::Cow;
2use std::path::PathBuf;
3
4use serde::{Deserialize, Serialize};
5use serde_with::serde_as;
6use tinymist_std::AsCowBytes;
7use typst::foundations::Dict;
8
9use crate::EntryOpts;
10
11#[serde_as]
12#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
13pub struct CompileOpts {
14    /// Path to entry
15    pub entry: EntryOpts,
16
17    /// Additional input arguments to compile the entry file.
18    pub inputs: Dict,
19
20    /// Path to font profile for cache
21    #[serde(rename = "fontProfileCachePath")]
22    pub font_profile_cache_path: PathBuf,
23
24    /// will remove later
25    #[serde(rename = "fontPaths")]
26    pub font_paths: Vec<PathBuf>,
27
28    /// Exclude system font paths
29    #[serde(rename = "noSystemFonts")]
30    pub no_system_fonts: bool,
31
32    /// Include embedded fonts
33    #[serde(rename = "withEmbeddedFonts")]
34    #[serde_as(as = "Vec<AsCowBytes>")]
35    pub with_embedded_fonts: Vec<Cow<'static, [u8]>>,
36}
37
38#[serde_as]
39#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
40pub struct CompileFontOpts {
41    /// Path to font profile for cache
42    #[serde(rename = "fontProfileCachePath")]
43    pub font_profile_cache_path: PathBuf,
44
45    /// will remove later
46    #[serde(rename = "fontPaths")]
47    pub font_paths: Vec<PathBuf>,
48
49    /// Exclude system font paths
50    #[serde(rename = "noSystemFonts")]
51    pub no_system_fonts: bool,
52
53    /// Include embedded fonts
54    #[serde(rename = "withEmbeddedFonts")]
55    #[serde_as(as = "Vec<AsCowBytes>")]
56    pub with_embedded_fonts: Vec<Cow<'static, [u8]>>,
57}
58
59impl From<CompileOpts> for CompileFontOpts {
60    fn from(opts: CompileOpts) -> Self {
61        Self {
62            font_profile_cache_path: opts.font_profile_cache_path,
63            font_paths: opts.font_paths,
64            no_system_fonts: opts.no_system_fonts,
65            with_embedded_fonts: opts.with_embedded_fonts,
66        }
67    }
68}