Device Detection and IP Intelligence for the 51Degrees Pipeline, in Rust

dd-onprem-match-metrics.rs File Reference

Classes

struct  ExampleOptions
 Options the example runs with. More...

Functions

pub struct ExampleOptions run (options:ExampleOptions) -> Result<()>
 Run the on-premise match-metrics example.
fn print_match_metrics (pipeline:&Arc< Pipeline >, pairs:&[(&str, &str)], available:&[String],) -> Result<()>
 Process one evidence set and print every match metric the on-premise engine exposes for the detection.
fn compare_property_count_timing (options:&ExampleOptions) -> Result<()>
 Time an engine restricted to one property against an engine returning every property, over the same evidence, and report that fewer properties is faster.
fn time_detections (pipeline:&Arc< Pipeline >, pairs:&[(&str, &str)], iterations:usize,) -> Result< Duration >
 Run iterations detections of pairs through pipeline and return the total elapsed time, touching a property each time so the work is not optimized away.
fn per_detection (total:Duration, iterations:usize) -> Duration
 The average time per detection, guarding against a zero iteration count.
fn output_value< T:std::fmt::Display > (name:&str, value:&AspectPropertyValue< T >, message:&mut String,)
 Append one typed property to the output, handling the no-value case.
fn output_enterprise (name:&str, value:&AspectPropertyValue< String >, available:&[String], message:&mut String,)
 Append a property only the Enterprise data file carries, or say that it needs the Enterprise data file when the data file in use does not carry it.

Variables

use std::fmt::Write as _
const ENTERPRISE_SHOWN
 The properties shown beside the metrics that only the Enterprise data file carries.
const HardwareName
const HardwareModel
const DeviceType
const const CONTACT_US_URL
 Where to ask about a copy of the Enterprise data file.
const const & str
pub data_file
 The path to the on-premise Hash data file the engine loads.
pub pub timing_iterations
 How many detections to run when timing the "fewer properties is faster" comparison.
trait HardwareNameJoined
 A small helper trait so the example can print a HardwareName list value through the same output_value path as the scalar properties.

Function Documentation

◆ compare_property_count_timing()

fn compare_property_count_timing ( options:& ExampleOptions) -> Result<()>

Time an engine restricted to one property against an engine returning every property, over the same evidence, and report that fewer properties is faster.

◆ output_enterprise()

fn output_enterprise ( name:& str,
value:&AspectPropertyValue< String > ,
available:& [String],
message:&mut String )

Append a property only the Enterprise data file carries, or say that it needs the Enterprise data file when the data file in use does not carry it.

◆ output_value< T:std::fmt::Display >()

fn output_value< T:std::fmt::Display > ( name:& str,
value:&AspectPropertyValue< T > ,
message:&mut String )

Append one typed property to the output, handling the no-value case.

◆ per_detection()

fn per_detection ( total:Duration ,
iterations:usize  ) -> Duration

The average time per detection, guarding against a zero iteration count.

◆ print_match_metrics()

fn print_match_metrics ( pipeline:&Arc< Pipeline > ,
pairs:& [(&str, &str)],
available:& [String] ) -> Result<()>

Process one evidence set and print every match metric the on-premise engine exposes for the detection.

available holds the properties the data file carries.

◆ run()

pub struct ExampleOptions run ( options:ExampleOptions ) -> Result<()>

Run the on-premise match-metrics example.

Processes a sample User-Agent and prints the detection match metrics (MatchedNodes, Difference, Drift, Iterations, Method and the DeviceId), then demonstrates that restricting the requested properties to a single component reduces detection time compared with requesting every property. It ends by naming the Enterprise properties the data file does not carry, with where to ask about a copy, and the "Find out more" links.

◆ time_detections()

fn time_detections ( pipeline:&Arc< Pipeline > ,
pairs:& [(&str, &str)],
iterations:usize  ) -> Result< Duration >

Run iterations detections of pairs through pipeline and return the total elapsed time, touching a property each time so the work is not optimized away.

Variable Documentation

◆ _

use std::fmt::Write as _

◆ CONTACT_US_URL

const const CONTACT_US_URL

Where to ask about a copy of the Enterprise data file.

◆ data_file

pub data_file

The path to the on-premise Hash data file the engine loads.

◆ DeviceType

const DeviceType

◆ ENTERPRISE_SHOWN

const ENTERPRISE_SHOWN

The properties shown beside the metrics that only the Enterprise data file carries.

The free Lite file carries none of them.

◆ HardwareModel

const HardwareModel

◆ HardwareName

const HardwareName

◆ HardwareNameJoined

trait HardwareNameJoined
Initial value:
{
fn hardware_name_joined(&self) -> AspectPropertyValue<String>

A small helper trait so the example can print a HardwareName list value through the same output_value path as the scalar properties.

◆ str

const const & str
Initial value:
= &[
("Device Detection", "/device-detection?utm_source=code&utm_medium=example&utm_campaign=51degrees-rust&utm_content=examples-device-detection-examples-src-bin-dd-onprem-match-metrics.rs&utm_term=find-out-more"),
("Pricing", "/pricing?utm_source=code&utm_medium=example&utm_campaign=51degrees-rust&utm_content=examples-device-detection-examples-src-bin-dd-onprem-match-metrics.rs&utm_term=find-out-more"),
("Documentation", "/documentation/index.html?utm_source=code&utm_medium=example&utm_campaign=51degrees-rust&utm_content=examples-device-detection-examples-src-bin-dd-onprem-match-metrics.rs&utm_term=find-out-more"),
]

◆ timing_iterations

pub pub timing_iterations

How many detections to run when timing the "fewer properties is faster" comparison.

Kept small in tests, larger from main for a steadier signal.