fiftyone_ip_intelligence_shared/lib.rs
1/* *********************************************************************
2 * This Original Work is copyright of 51 Degrees Mobile Experts Limited.
3 * Copyright 2026 51 Degrees Mobile Experts Limited, Davidson House,
4 * Forbury Square, Reading, Berkshire, United Kingdom RG1 3EU.
5 *
6 * This Original Work is licensed under the European Union Public Licence
7 * (EUPL) v.1.2 and is subject to its terms as set out below.
8 *
9 * If a copy of the EUPL was not distributed with this file, You can obtain
10 * one at https://opensource.org/licenses/EUPL-1.2.
11 *
12 * The 'Compatible Licences' set out in the Appendix to the EUPL (as may be
13 * amended by the European Commission) shall be deemed incompatible for
14 * the purposes of the Work and the provisions of the compatibility
15 * clause in Article 5 of the EUPL shall not apply.
16 *
17 * If using the Work as, or as part of, a network application, by
18 * including the attribution notice(s) required under Article 5 of the EUPL
19 * in the end user terms of the application under an appropriate heading,
20 * such notice(s) shall fulfill the requirements of that article.
21 * ********************************************************************* */
22
23//! [](https://51degrees.com/?utm_source=docs.rs&utm_medium=docs&utm_campaign=rust&utm_content=fiftyone-ip-intelligence-shared-lib.rs&utm_term=logo)
24//!
25//! # 51Degrees IP-intelligence shared model
26//!
27//! The IP-intelligence element data that the on-premise and cloud engines both
28//! build on, following the
29//! [ip-intelligence specification](https://github.com/51Degrees/specifications/tree/main/ip-intelligence-specification).
30//! Keeping these here, rather than in either engine crate, is what makes the two
31//! engines interface-compatible: both populate the same [`IpIntelligenceDataBase`]
32//! under the same [`IP_DATA_KEY`], so a consuming application can swap an
33//! on-premise engine for a cloud one (or the reverse) without touching its
34//! result-reading code. This mirrors the device-detection shared model in
35//! `fiftyone-device-detection-shared`.
36//!
37//! ## What the crate provides
38//!
39//! - [`IpIntelligenceData`], the read trait extending
40//! [`fiftyone_pipeline_engines::AspectData`] with one strongly-typed accessor
41//! per documented network and location property. Most properties are *plain*
42//! (a single typed value, for example a [`String`] country name, a [`bool`]
43//! `IsVPN` flag, an [`f32`] latitude or an [`i32`] offset); the few weighted
44//! properties (the country-code distributions and `Mcc`) return an ordered
45//! `Vec<`[`WeightedValue`](fiftyone_pipeline_core::WeightedValue)`<String>>`.
46//! Every accessor wraps its value in an
47//! [`AspectPropertyValue`](fiftyone_pipeline_engines::AspectPropertyValue) so
48//! an absent value carries the engine's no-value reason.
49//! - [`IpIntelligenceDataBase`], the concrete backing both engines populate. It
50//! embeds an [`AspectDataBase`](fiftyone_pipeline_engines::AspectDataBase) and
51//! keeps the typed values in dedicated stores beside it.
52//! - [`IP_DATA_KEY`], the [`TypedKey`](fiftyone_pipeline_core::TypedKey) used to
53//! store and retrieve the data, with the data key string `"ip"`.
54//! - [`GENERATED_PROPERTY_TYPES`] (and the [`generated_property_names`] and
55//! [`default_property_metadata`] / [`default_aspect_property_metadata`]
56//! helpers derived from it) a minimal wrapper can publish.
57//!
58//! The [`IpIntelligenceData`] trait and its accessor set are generated from the
59//! common metadata by the 51Degrees PropertyGenerator tool into an internal
60//! `ip_intelligence_data` module; the hand-written `data` module supplies the
61//! backing store the accessors delegate to. Both are re-exported here, so the
62//! crate root is the single import surface.
63
64#![warn(missing_docs)]
65
66mod data;
67mod ip_intelligence_data;
68
69pub use data::{
70 declared_property_value_type, default_aspect_property_metadata, default_property_metadata,
71 generated_property_names, IpIntelligenceDataBase, ValueStore, WeightedStore, IP_DATA_KEY,
72 IP_DATA_KEY_NAME, WEIGHTED_PROPERTY_VALUE_TYPE, WEIGHTED_RECORD_VALUE_KEY,
73 WEIGHTED_RECORD_WEIGHT_KEY,
74};
75pub use ip_intelligence_data::{IpIntelligenceData, GENERATED_PROPERTY_TYPES};