deb822_edit/
lib.rs

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
7mod common;
8mod lex;
9mod lossless;
10mod parse;
11pub use lossless::{Deb822, Entry, Error, Lang, Paragraph, ParseError, PositionedParseError};
12pub use parse::Parse;
13pub use rowan::TextRange;
14
15/// The indentation to use when writing a deb822 file.
16#[derive(Debug, Clone, Copy, PartialEq, Eq)]
17pub enum Indentation {
18    /// Use the same indentation as the original line for the value.
19    FieldNameLength,
20
21    /// The number of spaces to use for indentation.
22    Spaces(u32),
23}
24
25impl Default for Indentation {
26    fn default() -> Self {
27        Indentation::Spaces(4)
28    }
29}
30
31#[cfg(feature = "deb822-fast")]
32impl deb822_fast::convert::Deb822LikeParagraph for crate::lossless::Paragraph {
33    fn get(&self, key: &str) -> Option<String> {
34        crate::lossless::Paragraph::get(self, key).map(|v| v.to_string())
35    }
36
37    fn set(&mut self, key: &str, value: &str) {
38        crate::lossless::Paragraph::set(self, key, value);
39    }
40
41    fn remove(&mut self, key: &str) {
42        crate::lossless::Paragraph::remove(self, key);
43    }
44}