rtlola_frontend/tag_parser/
all.rs1use std::collections::{HashMap, HashSet};
4
5use rtlola_hir::hir::StreamReference;
6use rtlola_reporting::RtLolaError;
7
8use super::{TagParser, TagValidator};
9use crate::RtLolaMir;
10
11#[derive(Debug, Copy, Clone)]
12pub struct AllowAll;
14
15impl TagParser for AllowAll {
16 type GlobalTags = ();
17 type LocalTags = ();
18
19 fn parse_global(
20 &self,
21 _global_tags: &HashMap<String, Option<String>>,
22 _mir: &RtLolaMir,
23 ) -> Result<Self::GlobalTags, RtLolaError> {
24 Ok(())
25 }
26
27 fn parse_local(
28 &self,
29 _sr: StreamReference,
30 _tags: &HashMap<String, Option<String>>,
31 _mir: &RtLolaMir,
32 ) -> Result<Self::LocalTags, RtLolaError> {
33 Ok(())
34 }
35}
36
37impl TagValidator for AllowAll {
38 fn supported_tags<'a>(&self, mir: &'a RtLolaMir) -> (HashSet<&'a str>, HashSet<&'a str>) {
39 (mir.all_global_tags(), mir.all_local_tags())
40 }
41}
42
43#[derive(Debug, Copy, Clone)]
44pub struct DenyAll;
46
47impl TagParser for DenyAll {
48 type GlobalTags = ();
49 type LocalTags = ();
50
51 fn parse_global(
52 &self,
53 _global_tags: &HashMap<String, Option<String>>,
54 _mir: &RtLolaMir,
55 ) -> Result<Self::GlobalTags, RtLolaError> {
56 Ok(())
57 }
58
59 fn parse_local(
60 &self,
61 _sr: StreamReference,
62 _tags: &HashMap<String, Option<String>>,
63 _mir: &RtLolaMir,
64 ) -> Result<Self::LocalTags, RtLolaError> {
65 Ok(())
66 }
67}
68
69impl TagValidator for DenyAll {
70 fn supported_tags<'a>(&self, _mir: &'a RtLolaMir) -> (HashSet<&'a str>, HashSet<&'a str>) {
71 (HashSet::new(), HashSet::new())
72 }
73}