3 releases

0.1.2 Jul 29, 2024
0.1.1 Jul 9, 2024
0.1.0 Jun 18, 2024

#76 in Configuration

Download history 290/week @ 2024-07-27 204/week @ 2024-08-03 169/week @ 2024-08-10 148/week @ 2024-08-17 127/week @ 2024-08-24 99/week @ 2024-08-31 94/week @ 2024-09-07 87/week @ 2024-09-14 196/week @ 2024-09-21 64/week @ 2024-09-28 38/week @ 2024-10-05 215/week @ 2024-10-12 219/week @ 2024-10-19 202/week @ 2024-10-26 218/week @ 2024-11-02 102/week @ 2024-11-09

793 downloads per month
Used in configcat-openfeature-pro…

MIT license

195KB
4K SLoC

ConfigCat SDK for Rust

Build Status crates.io docs.rs

ConfigCat SDK for Rust provides easy integration for your application to ConfigCat.

Getting started

1. Install the package

Run the following Cargo command in your project directory:

cargo add configcat

Or add the following to your Cargo.toml:

[dependencies]
configcat = "0.1"

2. Go to the ConfigCat Dashboard to get your SDK Key:

SDK-KEY

3. Import the configcat module to your application

use configcat::*;

4. Create a ConfigCat client instance

use configcat::*;

#[tokio::main]
async fn main() {
    let client = Client::new("#YOUR-SDK-KEY#").unwrap();
}

5. Get your setting value

use configcat::*;

#[tokio::main]
async fn main() {
    let client = Client::new("#YOUR-SDK-KEY#").unwrap();

    let is_awesome_feature_enabled = client.get_value("isAwesomeFeatureEnabled", false, None).await;
    
    if is_awesome_feature_enabled {
        do_the_new_thing();
    } else {
        do_the_old_thing();
    }
}

Getting user specific setting values with Targeting

Using this feature, you will be able to get different setting values for different users in your application by passing a User Object to the get_value() function.

Read more about Targeting here.

use configcat::*;

#[tokio::main]
async fn main() {
    let client = Client::new("#YOUR-SDK-KEY#").unwrap();

    let user = User::new("#USER-IDENTIFIER#");
    let is_awesome_feature_enabled = client.get_value("isAwesomeFeatureEnabled", false, Some(user)).await;

    if is_awesome_feature_enabled {
        do_the_new_thing();
    } else {
        do_the_old_thing();
    }
}

Example

This repository contains a simple example application that you can run with:

cargo run --example print_eval

Polling Modes

The ConfigCat SDK supports 3 different polling mechanisms to acquire the setting values from ConfigCat. After latest setting values are downloaded, they are stored in the internal cache then all requests are served from there. Read more about Polling Modes and how to use them at ConfigCat Docs.

Need help?

https://configcat.com/support

Contributing

Contributions are welcome. For more info please read the Contribution Guideline.

About ConfigCat

ConfigCat is a feature flag and configuration management service that lets you separate releases from deployments. You can turn your features ON/OFF using ConfigCat Dashboard even after they are deployed. ConfigCat lets you target specific groups of users based on region, email or any other custom user attribute.

ConfigCat is a hosted feature flag service. Manage feature toggles across frontend, backend, mobile, desktop apps. Alternative to LaunchDarkly. Management app + feature flag SDKs.

Dependencies

~8–19MB
~257K SLoC