|
| const pub struct ExampleOptions | with_files (data_files:Vec< PathBuf >) -> Self |
| | Build options that look [IPS] up in each of data_files.
|
| pub fn | from_env () -> Option< Self > |
| | Build the default options through the shared resolver.
|
| pub fn | for_tier (tier:examples_shared::IpiTier) -> Option< Self > |
| | Build options pinned to a specific data-file tier.
|
| const pub fn | run (options:&ExampleOptions, out:&mut dyn Write) -> anyhow::Result<()> |
| | Run the getting-started example against the supplied options, writing all output to out.
|
| fn | look_up (data_file:&std::path::Path, ips:&[String], available:&[String], out:&mut dyn Write,) -> anyhow::Result<()> |
| | Build a pipeline over data_file, whose properties are available, and look each of ips up in it.
|
| fn | analyse_ip (pipeline:&Arc< Pipeline >, ip:&str, available:&[String], out:&mut dyn Write,) -> anyhow::Result<()> |
| | Look one IP address up and print its properties.
|
| fn | needs_enterprise (name:&str, available:&[String]) -> bool |
| | Whether name is an Enterprise property the data file in use does not carry, in which case its line says so in place of a value.
|
| fn | output_string (name:&str, property:&AspectPropertyValue< String >, available:&[String], out:&mut dyn Write,) -> anyhow::Result<()> |
| | Print a plain string property, or the no-value message when it is absent.
|
| fn | output_float (name:&str, property:&AspectPropertyValue< f32 >, available:&[String], out:&mut dyn Write,) -> anyhow::Result<()> |
| | Print a plain floating-point property (latitude, longitude).
|
| fn | output_integer (name:&str, property:&AspectPropertyValue< i32 >, available:&[String], out:&mut dyn Write,) -> anyhow::Result<()> |
| | Print a plain integer property (time-zone offset, accuracy radius).
|
| fn | output_bool (name:&str, property:&AspectPropertyValue< bool >, available:&[String], out:&mut dyn Write,) -> anyhow::Result<()> |
| | Print a plain boolean property (the network flags), as true/false.
|
| fn | output_weighted (name:&str, property:&AspectPropertyValue< Vec< WeightedValue< String > > >, available:&[String], out:&mut dyn Write,) -> anyhow::Result<()> |
| | Print a weighted property (the country-code distributions, Mcc) as a comma-separated list of value (weight) candidates ordered most probable first, or the no-value message when it is absent.
|
| fn | main () -> anyhow::Result<()> |
| | Read the data file, then run the example, writing to standard output.
|
| fn | getting_started_runs_against_the_asn_file () |
| | The example runs end to end against the real ASN data file and prints at least one autonomous-system value.
|
| fn analyse_ip |
( |
pipeline:&Arc< Pipeline > | , |
|
|
ip:& | str, |
|
|
available:& | [String], |
|
|
out:&mut dyn | Write ) -> anyhow::Result<()> |
Look one IP address up and print its properties.
available holds the properties the data file carries.
Build options pinned to a specific data-file tier.
main reads the Enterprise file or both free files, while the test pins to the ASN tier so it runs deterministically against the small, current, always-loadable ASN file rather than depending on the production Enterprise share being mounted.
| pub fn from_env |
( |
| ) |
-> Option< Self > |
Build the default options through the shared resolver.
A file named by _51DEGREES_IPI_PATH, or the Enterprise file when its share is reachable, is read alone. Otherwise both free files from the data repository are read, each downloaded when it is missing, being the ASN file for Asn and AsnName and the Lite file for the registered properties.
Returns [None] when no usable data file can be located, so the caller can report it rather than panicking.
| fn getting_started_runs_against_the_asn_file |
( |
| ) |
|
The example runs end to end against the real ASN data file and prints at least one autonomous-system value.
It skips cleanly when no data file is present, so a plain cargo test stays green offline.
The test pins the ASN tier so it always exercises the small, current, always-loadable ASN file, independent of whether the production Enterprise share happens to be mounted on the build machine.
| fn look_up |
( |
data_file:&std::path::Path | , |
|
|
ips:& | [String], |
|
|
available:& | [String], |
|
|
out:&mut dyn | Write ) -> anyhow::Result<()> |
Build a pipeline over data_file, whose properties are available, and look each of ips up in it.
| fn main |
( |
| ) |
-> anyhow::Result<()> |
Read the data file, then run the example, writing to standard output.
An optional command-line argument overrides the data-file path the shared resolver would otherwise pick.
| fn needs_enterprise |
( |
name:& | str, |
|
|
available:& | [String] ) -> bool |
Whether name is an Enterprise property the data file in use does not carry, in which case its line says so in place of a value.
| fn output_bool |
( |
name:& | str, |
|
|
property:&AspectPropertyValue< bool > | , |
|
|
available:& | [String], |
|
|
out:&mut dyn | Write ) -> anyhow::Result<()> |
Print a plain boolean property (the network flags), as true/false.
| fn output_float |
( |
name:& | str, |
|
|
property:&AspectPropertyValue< f32 > | , |
|
|
available:& | [String], |
|
|
out:&mut dyn | Write ) -> anyhow::Result<()> |
Print a plain floating-point property (latitude, longitude).
| fn output_integer |
( |
name:& | str, |
|
|
property:&AspectPropertyValue< i32 > | , |
|
|
available:& | [String], |
|
|
out:&mut dyn | Write ) -> anyhow::Result<()> |
Print a plain integer property (time-zone offset, accuracy radius).
| fn output_string |
( |
name:& | str, |
|
|
property:&AspectPropertyValue< String > | , |
|
|
available:& | [String], |
|
|
out:&mut dyn | Write ) -> anyhow::Result<()> |
Print a plain string property, or the no-value message when it is absent.
| fn output_weighted |
( |
name:& | str, |
|
|
property:&AspectPropertyValue< Vec< WeightedValue< String > > > | , |
|
|
available:& | [String], |
|
|
out:&mut dyn | Write ) -> anyhow::Result<()> |
Print a weighted property (the country-code distributions, Mcc) as a comma-separated list of value (weight) candidates ordered most probable first, or the no-value message when it is absent.
| const pub fn run |
( |
options:& | ExampleOptions, |
|
|
out:&mut dyn | Write ) -> anyhow::Result<()> |
Run the getting-started example against the supplied options, writing all output to out.
Builds an on-premise IP Intelligence pipeline for each data file, looks up each IP and prints the results. The pipeline is built with usage sharing left off, because this is a console example. A production deployment that wants to help improve the data should enable it (see the engine builder's share_usage equivalent on the cloud/web side). The output ends with the Enterprise properties no file carried, where to ask about a copy of the Enterprise data file, and the "Find out more" links.
Build options that look [IPS] up in each of data_files.
Where to ask about a copy of the Enterprise data file.
The full paths to the .ipi data files to open, each looked up in turn.
| const DISPLAYED_PROPERTIES |
Every property this example reads back and prints.
The on-premise engine narrows itself to the properties it is asked for, so the example must request the whole set it displays. Requesting only Asn and AsnName (which an ASN file carries beyond the curated typed set) would drop the registered-range and location properties, leaving them unset even with an Enterprise data file that carries them. Listing them all keeps every column populated when the data file has the value.
The addresses the example looks up, a public Cloudflare IPv4 and IPv6.
Both resolve to a real autonomous system in the ASN data file, so the example always has something to print.
The IP addresses to look up, as client-IP evidence values.