| 1 | #![deny(missing_docs)] |
| 2 | #![allow(clippy::type_complexity)] |
| 3 | #![doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/README.md"))] |
| 4 | // Until we drop support for PyO3 0.22, allow use of deprecated functions. |
| 5 | #![allow(deprecated)] |
| 6 | |
| 7 | mod common; |
| 8 | mod lex; |
| 9 | mod lossless; |
| 10 | mod parse; |
| 11 | pub use lex::SyntaxKind; |
| 12 | pub use lossless::{ |
| 13 | Deb822, Entry, Error, IndentPattern, Lang, Paragraph, ParseError, PositionedParseError, |
| 14 | }; |
| 15 | pub use parse::Parse; |
| 16 | pub use rowan::{TextRange, TextSize}; |
| 17 | |
| 18 | /// The indentation to use when writing a deb822 file. |
| 19 | #[derive(Debug, Clone, Copy, PartialEq, Eq)] |
| 20 | pub enum Indentation { |
| 21 | /// Use the same indentation as the original line for the value. |
| 22 | FieldNameLength, |
| 23 | |
| 24 | /// The number of spaces to use for indentation. |
| 25 | Spaces(u32), |
| 26 | } |
| 27 | |
| 28 | impl Default for Indentation { |
| 29 | fn default() -> Self { |
| 30 | Indentation::Spaces(4) |
| 31 | } |
| 32 | } |
| 33 | |
| 34 | #[cfg(feature = "deb822-fast")] |
| 35 | impl deb822_fast::convert::Deb822LikeParagraph for crate::lossless::Paragraph { |
| 36 | fn get(&self, key: &str) -> Option<String> { |
| 37 | crate::lossless::Paragraph::get(self, key).map(|v| v.to_string()) |
| 38 | } |
| 39 | |
| 40 | fn set(&mut self, key: &str, value: &str) { |
| 41 | crate::lossless::Paragraph::set(self, key, value); |
| 42 | } |
| 43 | |
| 44 | fn remove(&mut self, key: &str) { |
| 45 | crate::lossless::Paragraph::remove(self, key); |
| 46 | } |
| 47 | } |