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
//! This crate contains the LaunchDarkly Rust SDK feature flag evaluation engine.
//!
//! Normal use of the Rust SDK does not require referencing this crate directly. It is used internally
//! by the SDK, but is published and versioned separately so it can be used in other LaunchDarkly
//! components without making the SDK versioning dependent on these internal APIs.

#![deny(rustdoc::missing_crate_level_docs)]
#![deny(missing_docs)]

mod attribute_value;
mod contexts;
mod eval;
mod flag;
mod flag_value;
mod rule;
mod segment;
mod store;
mod test_common;
mod util;
mod variation;

pub use attribute_value::AttributeValue;
pub use contexts::attribute_reference::Reference;
pub use contexts::context::{Context, ContextAttributes, Kind};
pub use contexts::context_builder::{ContextBuilder, MultiContextBuilder};
pub use eval::*;
pub use flag::*;
pub use flag_value::*;
pub use rule::*;
pub use segment::*;
pub use store::*;
pub use variation::*;

#[cfg(test)]
pub(crate) mod proptest_generators {
    pub(crate) use crate::contexts::attribute_reference::proptest_generators::*;
    pub(crate) use crate::contexts::context::proptest_generators::*;
    pub(crate) use crate::rule::proptest_generators::*;
    pub(crate) use crate::variation::proptest_generators::*;
}

/// Trait indicating that the item is versioned.
pub trait Versioned {
    /// Retrieve the version for this item instance.
    fn version(&self) -> u64;

    /// Determine if this item's version is greater than or equal to the provided version
    /// parameter.
    fn is_greater_than_or_equal(&self, version: u64) -> bool {
        self.version() >= version
    }
}