polyvalue/
lib.rs

1//! # Polyvalue
2//! Single concrete type for representing values of different types
3//!
4//! This crate was built for use in a parser, where the type of a value is not known until runtime.
5//! Please open an issue if you have any suggestions for improvement.
6//!
7//! It provides a new type, [`Value`](crate::Value), which is an enum around a set of types implementing
8//! a common trait, [`ValueTrait`](crate::ValueTrait).
9//!
10//! All types will also implement all of the following:
11//! Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Hash, Serialize, Deserialize, Default
12//!
13//! The following types are provided:
14//! - [`Bool`](crate::types::Bool) : Wraps a `bool`
15//! - [`Int`](crate::types::Int) : Wraps an `i64`
16//! - [`Float`](crate::types::Float) : Wraps an `f64`
17//! - [`Fixed`](crate::types::Fixed) : Wraps an `fpdec::Decimal`, a fixed-point decimal type
18//! - [`Currency`](crate::types::Currency) : Wraps a `Fixed` and adds a currency symbol
19//! - [`Str`](crate::types::Str) : Wraps a `String`
20//! - [`Array`](crate::types::Array) : Wraps a `Vec<Value>`, providing an ordered set
21//! - [`Object`](crate::types::Object) : Wraps a `BTreeMap<Value, Value>`, providing a key-value store
22//!
23//! A set of traits for performing operations on values is also provided:
24//! - [`ArithmeticOperationExt`](crate::operations::ArithmeticOperationExt) : Operations such as addition, subtraction, etc.
25//! - [`BooleanOperationExt`](crate::operations::BooleanOperationExt) : Equality, comparisons, as well as AND and OR
26//! - [`BitwiseOperationExt`](crate::operations::BitwiseOperationExt) : Bitwise operations such as AND, OR, XOR, etc.
27//! - [`IndexingOperationExt`](crate::operations::IndexingOperationExt) : Indexing into arrays, objects, ranges, and strings
28//! - [`IndexingOperationExt`](crate::operations::IndexingOperationExt) : Indexing mutably into arrays and objects
29//!
30//! Note that while indexing into strings is supported, it is not provided through the `IndexOperationExt` trait.
31//! This is because we return substrings references, which have additional constraints. See [`Str`](crate::types::Str) for more information.
32//!
33#![doc(html_root_url = "https://docs.rs/polyvalue/0.3.0")]
34#![warn(missing_docs)]
35
36#[macro_use]
37mod macros;
38
39mod inner_types;
40mod is_currency;
41
42mod error;
43pub use error::Error;
44
45mod tagged_value;
46mod value;
47pub use value::*;
48
49mod value_type;
50pub use value_type::*;
51
52pub mod operations;
53pub mod types;
54
55// We will export the fpdec crate as well, so that users can use it directly
56
57/// Fixed-point decimal type used by [`Fixed`](crate::types::Fixed) and [`Currency`](crate::types::Currency)
58/// See the [`fpdec`](https://docs.rs/fpdec) crate for more information
59pub use fpdec;