jsonschema_annotator/annotator/
mod.rs1mod toml;
2mod yaml;
3
4pub use self::toml::TomlAnnotator;
5pub use self::yaml::YamlAnnotator;
6
7use crate::error::AnnotatorError;
8use crate::schema::AnnotationMap;
9
10#[derive(Debug, Clone)]
12pub struct AnnotatorConfig {
13 pub include_title: bool,
15 pub include_description: bool,
17 pub max_line_width: Option<usize>,
19 pub preserve_existing: bool,
21}
22
23impl Default for AnnotatorConfig {
24 fn default() -> Self {
25 Self {
26 include_title: true,
27 include_description: true,
28 max_line_width: Some(80),
29 preserve_existing: true,
30 }
31 }
32}
33
34impl AnnotatorConfig {
35 pub fn titles_only() -> Self {
37 Self {
38 include_title: true,
39 include_description: false,
40 ..Default::default()
41 }
42 }
43
44 pub fn descriptions_only() -> Self {
46 Self {
47 include_title: false,
48 include_description: true,
49 ..Default::default()
50 }
51 }
52}
53
54pub trait Annotator {
56 fn annotate(
58 &self,
59 content: &str,
60 annotations: &AnnotationMap,
61 ) -> Result<String, AnnotatorError>;
62}