1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
//! A crate to work with Telegram Desktop themes. Supports:
//!
//! - Parsing of `.tdesktop-palette`;
//! - Parsing of `.tdesktop-theme`;
//! - Serialization to `.tdesktop-palette` format;
//! - Serialization to `.tdesktop-theme` format;
//! - Dealing with wallpapers;
//! - Editing themes;
//! - Variables links.
//!
//! Also can:
//! - Resolve links;
//! - Unlink variables;
//! - Add themes (`&theme + &other_theme`);
//! - Fallback to another theme (`&theme | &other_theme`);
//! - Provide you with Telegram's default themes.
//!
//! We also provide the default themes under the `default_themes` module.
//! If you think we don't support something or you wish we had some feature,
//! feel free to [fill an issue on our GitLab repository][issues].
//!
//! [issues]: https://gitlab.com/SnejUgal/tdesktop-theme-rs/issues
#[cfg_attr(test, macro_use)]
extern crate indexmap;
pub mod default_themes;
mod parse;
mod serialize;
mod tdesktop_theme;
pub mod utils;
mod wallpaper;
use indexmap::IndexMap;
pub use parse::ParseError;
pub use tdesktop_theme::*;
pub use wallpaper::*;
/// An array that represents a color, in the format
/// `[red, green, blue, alpha]`.
///
/// An array was chosen because it is usable with other crates, unlike if this
/// crate used his own struct.
type Color = [u8; 4];
type Variables = IndexMap<String, Value>;
/// Represents a possible variable's value.
#[derive(Debug, PartialEq, Clone)]
pub enum Value {
/// Holds the color of the variable.
Color(Color),
/// Holds the variable's link to another variable.
///
/// # Notes
///
/// Tt's not guaranteed that the theme really has the variable this field
/// holds a link to.
///
/// To get the variable's real value, use `TdesktopTheme.resolve_variable`.
Link(String),
}