]> git.proxmox.com Git - rustc.git/blob - vendor/gix-config-value/src/lib.rs
New upstream version 1.74.1+dfsg1
[rustc.git] / vendor / gix-config-value / src / lib.rs
1 //! Parsing for data types used in `git-config` files to allow their use from environment variables and other sources.
2 //!
3 //! ## Feature Flags
4 #![cfg_attr(
5 feature = "document-features",
6 cfg_attr(doc, doc = ::document_features::document_features!())
7 )]
8 #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
9 #![deny(missing_docs, rust_2018_idioms, unsafe_code)]
10
11 /// The error returned when any config value couldn't be instantiated due to malformed input.
12 #[derive(Debug, thiserror::Error, Eq, PartialEq)]
13 #[allow(missing_docs)]
14 #[error("Could not decode '{input}': {message}")]
15 pub struct Error {
16 pub message: &'static str,
17 pub input: bstr::BString,
18 #[source]
19 pub utf8_err: Option<std::str::Utf8Error>,
20 }
21
22 impl Error {
23 /// Create a new value error from `message`, with `input` being what's causing the error.
24 pub fn new(message: &'static str, input: impl Into<bstr::BString>) -> Self {
25 Error {
26 message,
27 input: input.into(),
28 utf8_err: None,
29 }
30 }
31
32 pub(crate) fn with_err(mut self, err: std::str::Utf8Error) -> Self {
33 self.utf8_err = Some(err);
34 self
35 }
36 }
37
38 mod boolean;
39 ///
40 pub mod color;
41 ///
42 pub mod integer;
43 ///
44 pub mod path;
45
46 mod types;
47 pub use types::{Boolean, Color, Integer, Path};