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

dd-cloud-configurator.rs File Reference

Classes

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

Functions

pub struct ExampleOptions with_resource_key (resource_key:String) -> Self
 Default options for a resource key: the sample origin and the cloud endpoint from the environment, or the public cloud when unset.
pub fn run (options:ExampleOptions) -> Result<()>
 Run the cloud configurator example.
fn build_pipeline (options:&ExampleOptions) -> Result< Arc< Pipeline > >
 Assemble the cloud pipeline from the resource-key configuration.
fn main () -> Result<()>
 Read the resource key from the command line or the environment, then run.
fn pipeline_builds_offline_with_injected_state ()
fn runs_against_the_cloud ()

Variables

const FIND_OUT_MORE
 The links the example's output ends with.
const & str
const CLOUD_REQUEST_ORIGIN
 The cloud request origin the configured key is locked to.
pub resource_key
 The cloud resource key created in the configurator.
pub pub endpoint
 An optional override for the cloud endpoint.
pub pub pub cloud_request_origin
 The cloud request origin to send.
mod tests

Function Documentation

◆ build_pipeline()

fn build_pipeline ( options:& ExampleOptions) -> Result< Arc< Pipeline > >

Assemble the cloud pipeline from the resource-key configuration.

The pipeline is built by hand (rather than through the convenience builder) so every piece of the resource-key configuration is explicit: the resource key and endpoint on the request engine, the cloud request origin, and the device engine that turns the response into a result. The convenience DeviceDetectionPipelineBuilder::cloud does the same wiring but does not expose the origin, which this example specifically illustrates.

◆ main()

fn main ( ) -> Result<()>

Read the resource key from the command line or the environment, then run.

◆ pipeline_builds_offline_with_injected_state()

fn pipeline_builds_offline_with_injected_state ( )

◆ run()

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

Run the cloud configurator example.

Builds the cloud pipeline by hand so the full resource-key configuration is visible (the resource key, the cloud endpoint, and the cloud request origin), then runs a single User-Agent Client Hints detection through it and prints IsMobile.

◆ runs_against_the_cloud()

fn runs_against_the_cloud ( )

◆ with_resource_key()

pub struct ExampleOptions with_resource_key ( resource_key:String ) -> Self

Default options for a resource key: the sample origin and the cloud endpoint from the environment, or the public cloud when unset.

Variable Documentation

◆ CLOUD_REQUEST_ORIGIN

const CLOUD_REQUEST_ORIGIN

The cloud request origin the configured key is locked to.

A resource key created in the configurator can be restricted to one or more origins. The matching Origin header value is sent with every request so the cloud accepts it.

◆ cloud_request_origin

pub pub pub cloud_request_origin

The cloud request origin to send.

Defaults to [CLOUD_REQUEST_ORIGIN]. Set to None to send no origin header.

◆ endpoint

pub pub endpoint

An optional override for the cloud endpoint.

◆ FIND_OUT_MORE

const FIND_OUT_MORE

The links the example's output ends with.

◆ resource_key

pub resource_key

The cloud resource key created in the configurator.

◆ str

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-cloud-configurator.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-cloud-configurator.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-cloud-configurator.rs&utm_term=find-out-more"),
]

◆ tests

mod tests
Initial value:
{
use super::*