Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

featurevisor-example-rust

A small Rust application showing how to consume the published Featurevisor Rust SDK from crates.io.

The application downloads a Featurevisor datafile, creates an SDK instance, sets a context, and evaluates one feature as a flag, variation, and string variable.

Requirements

Rust 1.74 or newer.

Run it

cargo run

The application fetches this production datafile:

https://featurevisor-example-cloudflare.pages.dev/production/featurevisor-mobile.json

The important SDK usage is in src/main.rs:

use featurevisor::{context, create_featurevisor, DatafileInput, FeaturevisorOptions};

let f = create_featurevisor(FeaturevisorOptions {
    datafile: Some(DatafileInput::Json(datafile)),
    ..Default::default()
});

f.set_context(
    context! {
        "userId" => "mobile-user",
        "country" => "nl",
    },
    false,
);

let enabled = f.is_enabled("mobile_experience", None);
let variation = f.get_variation("mobile_experience", None, None);
let welcome_message = f.get_variable_string(
    "mobile_experience",
    "welcome_message",
    None,
    None,
);

The featurevisor dependency comes from crates.io. It is not a local path dependency, so this project demonstrates the same setup used by a new consumer.

Learn more in the Featurevisor Rust SDK documentation.

Featurevisor project

The datafile is generated by the Featurevisor example Cloudflare project.

About

Example Rust application using Featurevisor SDK

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages