1#![deny(missing_docs)]
2#[cfg(feature = "linebased")]
31mod lex;
32#[cfg(feature = "linebased")]
33pub mod linebased;
35
36#[cfg(all(feature = "deb822", feature = "linebased"))]
37mod convert;
38#[cfg(feature = "deb822")]
39pub mod deb822;
40#[cfg(all(feature = "discover", any(feature = "linebased", feature = "deb822")))]
41pub mod discover;
42pub mod mangle;
43#[cfg(feature = "pgp")]
44pub mod pgp;
45pub mod release;
46pub mod search;
47#[cfg(feature = "deb822")]
48pub mod templates;
49
50pub const DEFAULT_VERSION: u32 = 1;
53
54#[cfg(any(feature = "linebased", feature = "deb822"))]
55pub mod parse;
56pub mod subst;
57mod types;
58pub const DEFAULT_USER_AGENT: &str = concat!("debian-watch-rs/", env!("CARGO_PKG_VERSION"));
60
61pub use release::Release;
62pub use types::*;
63
64#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
67#[allow(non_camel_case_types, missing_docs, clippy::upper_case_acronyms)]
68#[repr(u16)]
69pub enum SyntaxKind {
70 KEY = 0,
71 VALUE,
72 EQUALS,
73 QUOTE,
74 COMMA,
75 CONTINUATION,
76 NEWLINE,
77 WHITESPACE, COMMENT, ERROR, ROOT, VERSION, ENTRY, OPTS_LIST, OPTION, OPTION_SEPARATOR, URL, MATCHING_PATTERN, VERSION_POLICY, SCRIPT, }
93
94impl From<SyntaxKind> for rowan::SyntaxKind {
96 fn from(kind: SyntaxKind) -> Self {
97 Self(kind as u16)
98 }
99}
100
101#[cfg(all(feature = "deb822", feature = "linebased"))]
106pub use crate::convert::{convert_to_v5, ConversionError};
107
108#[cfg(all(test, feature = "linebased"))]
109mod tests {
110 use crate::linebased::WatchFile;
111
112 #[test]
113 fn test_create_watchfile() {
114 let wf = WatchFile::new(None);
115 assert_eq!(wf.version(), super::DEFAULT_VERSION);
116
117 assert_eq!("", wf.to_string());
118
119 let wf = WatchFile::new(Some(4));
120 assert_eq!(wf.version(), 4);
121
122 assert_eq!("version=4\n", wf.to_string());
123 }
124
125 #[test]
126 fn test_set_version() {
127 let mut wf = WatchFile::new(Some(4));
128 assert_eq!(wf.version(), 4);
129
130 wf.set_version(5);
131 assert_eq!(wf.version(), 5);
132 assert_eq!("version=5\n", wf.to_string());
133
134 let mut wf = WatchFile::new(None);
136 assert_eq!(wf.version(), super::DEFAULT_VERSION);
137
138 wf.set_version(4);
139 assert_eq!(wf.version(), 4);
140 assert_eq!("version=4\n", wf.to_string());
141 }
142
143 #[test]
144 fn test_set_version_on_parsed() {
145 let mut wf: WatchFile = "version=4\n".parse().unwrap();
147 assert_eq!(wf.version(), 4);
148
149 wf.set_version(5);
150 assert_eq!(wf.version(), 5);
151 assert_eq!("version=5\n", wf.to_string());
152
153 let mut wf: WatchFile = "".parse().unwrap();
155 assert_eq!(wf.version(), super::DEFAULT_VERSION);
156
157 wf.set_version(4);
158 assert_eq!(wf.version(), 4);
159 assert_eq!("version=4\n", wf.to_string());
160 }
161}