pub struct IpIntelligenceDataBase { /* private fields */ }Expand description
The concrete IP-intelligence element data both engines produce.
Embeds an AspectDataBase for the standard aspect plumbing (the dynamic
property bag, the engine keys and the cache-hit flag) and keeps the typed
values in dedicated stores next to it: one plain store per value type, plus a
weighted store for the genuinely weighted properties. The generated
IpIntelligenceData accessors read these stores
by name; the dynamic ElementData bag holds a mirror so string-keyed
lookups also work.
Implementations§
Source§impl IpIntelligenceDataBase
impl IpIntelligenceDataBase
Sourcepub fn new(engine_key: impl Into<String>) -> Self
pub fn new(engine_key: impl Into<String>) -> Self
Create empty IP-intelligence data attributed to the engine with the given
data key (typically IP_DATA_KEY_NAME).
Sourcepub fn from_base(base: AspectDataBase) -> Self
pub fn from_base(base: AspectDataBase) -> Self
Create IP-intelligence data wrapping an existing AspectDataBase,
preserving its bag, engine keys and cache-hit flag.
Sourcepub fn base(&self) -> &AspectDataBase
pub fn base(&self) -> &AspectDataBase
Borrow the embedded AspectDataBase.
Sourcepub fn base_mut(&mut self) -> &mut AspectDataBase
pub fn base_mut(&mut self) -> &mut AspectDataBase
Mutably borrow the embedded AspectDataBase.
Sourcepub fn set_cache_hit(&mut self)
pub fn set_cache_hit(&mut self)
Mark this data as having been served from a cache hit.
Sourcepub fn add_engine_key(&mut self, engine_key: impl Into<String>)
pub fn add_engine_key(&mut self, engine_key: impl Into<String>)
Record that another engine (by data key) also contributed to this data.
Sourcepub fn set_string(&mut self, name: impl AsRef<str>, value: impl Into<String>)
pub fn set_string(&mut self, name: impl AsRef<str>, value: impl Into<String>)
Store a plain string-valued property and its dynamic-bag mirror.
This is the entry point a wrapper calls for the registered-range and textual location properties (including the IP range bounds). The property name is matched case-insensitively by the accessors and the dynamic bag.
Sourcepub fn set_float(&mut self, name: impl AsRef<str>, value: f32)
pub fn set_float(&mut self, name: impl AsRef<str>, value: f32)
Store a plain single-precision float property (Latitude, Longitude)
and its dynamic-bag mirror.
Sourcepub fn set_integer(&mut self, name: impl AsRef<str>, value: i32)
pub fn set_integer(&mut self, name: impl AsRef<str>, value: i32)
Store a plain integer property (TimeZoneOffset, AccuracyRadiusMin,
the diversity scores) and its dynamic-bag mirror.
Sourcepub fn set_boolean(&mut self, name: impl AsRef<str>, value: bool)
pub fn set_boolean(&mut self, name: impl AsRef<str>, value: bool)
Store a plain boolean property (IsBroadband, IsVPN, IsEu, and the
rest of the network flags) and its dynamic-bag mirror.
Sourcepub fn set_weighted_string(
&mut self,
name: impl AsRef<str>,
values: Vec<WeightedValue<String>>,
)
pub fn set_weighted_string( &mut self, name: impl AsRef<str>, values: Vec<WeightedValue<String>>, )
Store a weighted string property (CountryCodesGeographical,
CountryCodesPopulation, Mcc) and its dynamic-bag mirror.
The list is sorted high weighting first and mirrored into the dynamic bag
as a PropertyValue::KeyValueList of value/weight records.
Sourcepub fn set_string_no_value(
&mut self,
name: impl AsRef<str>,
message: impl Into<String>,
)
pub fn set_string_no_value( &mut self, name: impl AsRef<str>, message: impl Into<String>, )
Record that a string-valued property had no value, with an explanatory message. The matching accessor then returns a no-value carrying it.
Sourcepub fn set_float_no_value(
&mut self,
name: impl AsRef<str>,
message: impl Into<String>,
)
pub fn set_float_no_value( &mut self, name: impl AsRef<str>, message: impl Into<String>, )
Record that a float-valued property had no value, with a message.
Sourcepub fn set_integer_no_value(
&mut self,
name: impl AsRef<str>,
message: impl Into<String>,
)
pub fn set_integer_no_value( &mut self, name: impl AsRef<str>, message: impl Into<String>, )
Record that an integer property had no value, with a message.
Sourcepub fn set_boolean_no_value(
&mut self,
name: impl AsRef<str>,
message: impl Into<String>,
)
pub fn set_boolean_no_value( &mut self, name: impl AsRef<str>, message: impl Into<String>, )
Record that a boolean property had no value, with a message.
Sourcepub fn set_weighted_string_no_value(
&mut self,
name: impl AsRef<str>,
message: impl Into<String>,
)
pub fn set_weighted_string_no_value( &mut self, name: impl AsRef<str>, message: impl Into<String>, )
Record that a weighted string property had no value, with a message.
Sourcepub fn string(&self, name: &str) -> AspectPropertyValue<String>
pub fn string(&self, name: &str) -> AspectPropertyValue<String>
Read a plain string property by name, as the generated string accessors do.
Sourcepub fn float(&self, name: &str) -> AspectPropertyValue<f32>
pub fn float(&self, name: &str) -> AspectPropertyValue<f32>
Read a plain float property by name.
Sourcepub fn integer(&self, name: &str) -> AspectPropertyValue<i32>
pub fn integer(&self, name: &str) -> AspectPropertyValue<i32>
Read a plain integer property by name.
Sourcepub fn boolean(&self, name: &str) -> AspectPropertyValue<bool>
pub fn boolean(&self, name: &str) -> AspectPropertyValue<bool>
Read a plain boolean property by name.
Sourcepub fn weighted_string(
&self,
name: &str,
) -> AspectPropertyValue<Vec<WeightedValue<String>>>
pub fn weighted_string( &self, name: &str, ) -> AspectPropertyValue<Vec<WeightedValue<String>>>
Read a weighted string property by name.
Returns AspectPropertyValue::NoValue when the property is absent or
was recorded as a no-value. The list is ordered high weighting first.
This is how the genuinely weighted properties (CountryCodesGeographical,
CountryCodesPopulation, Mcc) are read.
Trait Implementations§
Source§impl AspectData for IpIntelligenceDataBase
impl AspectData for IpIntelligenceDataBase
Source§impl Clone for IpIntelligenceDataBase
impl Clone for IpIntelligenceDataBase
Source§fn clone(&self) -> IpIntelligenceDataBase
fn clone(&self) -> IpIntelligenceDataBase
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for IpIntelligenceDataBase
impl Debug for IpIntelligenceDataBase
Source§impl ElementData for IpIntelligenceDataBase
impl ElementData for IpIntelligenceDataBase
Source§fn get(&self, name: &str) -> Result<PropertyValue, NoValueError>
fn get(&self, name: &str) -> Result<PropertyValue, NoValueError>
Source§fn keys(&self) -> Vec<String>
fn keys(&self) -> Vec<String>
Source§fn as_any(&self) -> &dyn Any
fn as_any(&self) -> &dyn Any
&dyn Any for downcasting to the concrete type.Source§fn as_any_mut(&mut self) -> &mut dyn Any
fn as_any_mut(&mut self) -> &mut dyn Any
&mut dyn Any for downcasting to the concrete type.