ostrya-core 0.18.0

ostree object model, checksums, on-disk format primitives, and typed config
Documentation
//! The typed config API. It holds the traits of the groups and the keys, the
//! text form of a value, and the error of the typed reads and edits. The
//! module also holds the macro that defines a group, the groups `[core]` and
//! `[ex-integrity]`, and the typed reads and edits of a key file. It holds
//! the value types of the keys of the port that use no item of `ostrya`.
//!
//! - [`Group`], [`Key`], [`SingleKey`], [`Overridable`], and [`Settable`]
//!   are the traits of the keys and the groups. [`UserGroup`] is the trait
//!   of a group of a library user.
//! - [`Value`] is the text form of a value, and [`ValueError`] is its parse
//!   error.
//! - [`decode_string`], [`encode_string`], [`decode_bool`], [`encode_bool`],
//!   [`decode_integer`], [`encode_integer`], [`decode_string_list`], and
//!   [`encode_string_list`] read and write the text of the key file.
//! - [`ConfigView`] reads the keys of a key file through the key types.
//! - [`Section`] reads one section of a named group, and [`RemoteSource`]
//!   names the file that holds a section.
//! - [`ConfigEdit`] and [`SectionMut`] edit a key file through the key
//!   types.
//! - [`Lookup`] gives a value and its source.
//! - [`ConfigError`] is the error of the typed reads and edits, for example
//!   a [`ValueError`] with its group and its key. The `ostrya` crate converts
//!   each variant to the variant of `ostrya::Error` with the same name, with
//!   the same text.
//! - [`config_group!`](crate::config_group) defines a group and its keys.
//! - The modules [`repo`] and [`ex_integrity`] hold one key type for each key
//!   that the port reads in `[core]` and `[ex-integrity]`.
//! - The value types [`Tristate`], [`SignVerify`], [`SizeSpec`],
//!   [`SizeUnit`], [`LockTimeout`], [`FreeSpacePercent`],
//!   [`CollectionIdValue`], [`RemotesConfigPath`], [`ConfigPath`],
//!   [`KeyringPaths`], [`CollectionIdList`], [`ListenAddrs`], [`PemPath`],
//!   [`PositiveInt`], [`UploadStreams`], [`KeyGroupNames`], [`DottedOid`],
//!   [`X509Identities`], and [`SigningKeyType`] hold a checked value of a key
//!   of the port.
//!   [`GroupRef`] names a section of a named group.
//!
//! The overrides of a repository handle and the reads of one key with these
//! overrides are hidden items of this module. The `ostrya` crate reads the
//! repository `config` with them.
//!
//! The `ostrya` crate re-exports each public item under `ostrya::config`, and
//! the macro as `ostrya::config_group!`.

mod edit;
mod error;
mod group_macro;
mod groups;
mod lookup;
mod overrides;
mod read;
mod section;
mod typed;
mod types;
mod value;
mod view;

pub use edit::{ConfigEdit, SectionMut};
pub use error::ConfigError;
pub use groups::{ex_integrity, repo};
pub use lookup::Lookup;
#[doc(hidden)]
pub use overrides::{Entry, Overrides, find as find_entry, put as put_entry, put_settable};
#[doc(hidden)]
pub use read::{
    is_section_name, lookup, lookup_text, read_file, read_in_effect, refuse_unknown_keys,
    section_header, section_name,
};
pub use section::{RemoteSource, Section};
pub use typed::{Group, Key, Overridable, Settable, SingleKey, UserGroup};
#[doc(hidden)]
pub use typed::{OutputOf, ValueOf, lists, sealed, str_eq};
#[doc(hidden)]
pub use types::relative_with_parent;
pub use types::{
    CollectionIdList, CollectionIdValue, ConfigPath, DottedOid, FreeSpacePercent, GroupRef,
    KeyGroupNames, KeyringPaths, ListenAddrs, LockTimeout, PemPath, PositiveInt, RemotesConfigPath,
    SignVerify, SigningKeyType, SizeSpec, SizeUnit, Tristate, UploadStreams, X509Identities,
};
#[doc(hidden)]
pub use value::value_error;
pub use value::{
    Value, ValueError, decode_bool, decode_integer, decode_string, decode_string_list, encode_bool,
    encode_integer, encode_string, encode_string_list,
};
pub use view::ConfigView;

/// The groups of the tests of the module.
#[cfg(test)]
mod test_groups {
    use super::GroupRef;

    /// The `[core]` group of a key file of a test.
    pub(crate) const BASE: &str = "[core]\nrepo_version=1\nmode=bare\n";

    crate::config_group! {
        /// A single group of a test.
        pub group test_single = "ex-test", closed {
            Name: Option<String> = "name";
            Jobs: u32 = "jobs", default 4;
        }
    }

    crate::config_group! {
        /// A named group of a test.
        pub group test_named = named "ex-test n", closed {
            Arch: String = "arch", required;
            Tags: Vec<String> = "tags", default Vec::new();
            Next: Option<GroupRef<test_named::Group>> = "next";
        }
    }
}