FunnelMob

Rust SDK

Rust SDK - Remote Config

Read remote config values with the FunnelMob Rust SDK.

Remote Config lets you change values in your app without shipping a new build. Define keys in the FunnelMob dashboard (under Feature Management → Remote Config), and read them from the SDK at runtime to flip features on or off, tune values, or roll out experiments.

The SDK fetches config in a background thread when you call FunnelMob::new(...), holds it in memory for the process lifetime, and exposes thread-safe getters that work even before the network call completes (using default values).

Reading values

// Untyped — returns Option<serde_json::Value>
let raw = sdk.get_config("welcome_message");
 
// Typed with a default — deserializes via serde, falls back if missing or wrong type
let message: String = sdk.get_config_or("welcome_message", "Welcome!".to_string());
let max_retries: u32 = sdk.get_config_or("max_retry_attempts", 3);
let dark_mode: bool = sdk.get_config_or("dark_mode_default", false);
 
// Get everything at once
let all = sdk.get_all_config();

The get_config_or overload is the recommended way to read values — it deserializes via serde::de::DeserializeOwned and gives you a guaranteed fallback if the key isn't set or the dashboard value is the wrong type.

Reacting when config loads

If you need to react the first time config arrives (for example, to render a paywall whose copy is configured remotely), register a callback:

sdk.on_config_loaded(|config| {
    // config: &HashMap<String, serde_json::Value>
    println!("Config loaded with {} keys", config.len());
});

The callback fires immediately if config is already loaded, so you don't need to special-case the "already loaded" path. Callbacks must be Send + Sync + 'static.

Caching behavior

LayerWhereTTL
In-memoryArc<RwLock<...>> on the SDK instanceProcess lifetime
Disk— (none)
ServerRedis (transparent to SDK)Invalidated on dashboard edits

Unlike the iOS, Android, and Web SDKs, the Rust SDK does not persist config to disk. Each new FunnelMob::new(...) triggers a fresh background fetch. For long-running services this is rarely an issue, but if you create and drop SDK instances frequently you'll hit the network each time.

If you need values immediately at startup (before the background fetch completes), call on_config_loaded and gate the dependent work on the callback, or rely on the defaults you pass to get_config_or.

Supported value types

Set values in the dashboard as one of: string, number, boolean, or json. The SDK delivers them as serde_json::Value, so anything that implements serde::de::DeserializeOwned works:

use serde::Deserialize;
 
#[derive(Deserialize)]
struct FeatureFlags {
    new_dashboard: bool,
    beta_analytics: bool,
    ai_insights: bool,
}
 
let flags: FeatureFlags = sdk.get_config_or(
    "feature_flags",
    FeatureFlags { new_dashboard: false, beta_analytics: false, ai_insights: false },
);
 
if flags.ai_insights {
    enable_ai_panel();
}

Common patterns

Feature flags

if sdk.get_config_or("new_checkout_enabled", false) {
    run_new_checkout();
} else {
    run_legacy_checkout();
}

Tuning values without a release

let timeout_ms: u64 = sdk.get_config_or("api_timeout_ms", 30_000);
let client = reqwest::Client::builder()
    .timeout(std::time::Duration::from_millis(timeout_ms))
    .build()?;

Server-driven copy

let welcome: String = sdk.get_config_or("welcome_message", "Welcome!".to_string());
println!("{}", welcome);