Skip to main content
Every public symbol exported by westyx-nexus. All read methods are non-blocking - they hit the in-memory cache. Only NexusClient::create and sync make network calls.

Construction

NexusClient::create(config: NexusConfig) -> Result<NexusClient, NexusError>

Creates a client and runs a blocking initial sync. Returns the populated client, or a NexusError.

Configs

fn get_config(&self, key: &str) -> Option<serde_json::Value>

Returns the resolved config value, or None when the key is not in the cache.
The value is a serde_json::Value - use .as_str(), .as_f64(), .as_bool(), or deserialise into a typed struct with serde_json::from_value.

fn get_all_configs(&self) -> HashMap<String, serde_json::Value>

Snapshot copy of every config key-value pair currently in the cache. The returned map is independent of the SDK’s internal storage; mutating it has no effect.

Feature flags

fn get_flag(&self, key: &str, default_value: bool) -> bool

Returns the is_active state of a flag, or default_value when the key is absent.
The backend computes is_active from is_enabled, starts_at, and ends_at. The SDK never recomputes this.

fn get_all_flags(&self) -> HashMap<String, bool>

Snapshot copy of every flag key-is_active pair in the cache.

Secrets (secret key only)

fn get_secret(&self, key: &str) -> Result<String, NexusError>

Returns the plaintext value of a secret. Works for both text-type and file-type secrets - for file-type secrets it returns the raw file contents as a String.

fn get_secret_file_path(&self, key: &str) -> Result<PathBuf, NexusError>

Returns the PathBuf of the temp file that holds the value of a file-type secret. The SDK materialises every file-type secret to disk on every sync at:
The hash prefix is derived from the secret value, so the path changes when the value changes. Files are written with mode 0o600.
Returns the same NexusError variants as get_secret when the key is absent, the client uses a public key, the kind is "frontend", or the secret is not of file type.

Write methods (secret key only)

Write methods issue network calls and return errors if the client uses a public key.

fn set_secret(&self, key: &str, value: &str) -> Result<(), NexusError>

Creates or updates a secret value.

fn delete_secret(&self, key: &str) -> Result<(), NexusError>

Deletes a secret and all its versions.

fn delete_secret_version(&self, key: &str, version: u32) -> Result<(), NexusError>

Deletes a specific version of a secret, leaving other versions intact.

A/B testing

fn evaluate_ab(&self, keys: &[&str], user_id: &str, attributes: &HashMap<String, Value>) -> Result<HashMap<String, bool>, NexusError>

Batch-evaluates feature flags through the AB Testing add-on. Issues a single POST /v1/flags/evaluate-ab and returns a map of flag key to evaluated boolean. Unlike get_flag, this method always performs a network call and does not consult the local cache.

SSE

fn run_stream(&self)

Spawns a background std::thread that holds a persistent GET /v1/stream SSE connection. Non-blocking - returns immediately after spawning the thread.
The background thread triggers a full sync on every change event. After 3 consecutive transport errors, the thread exits and the SDK falls back to TTL polling. See SSE live updates for full semantics.

Manual sync

fn sync(&self) -> Result<(), NexusError>

Forces a sync now, bypassing the TTL. Atomically replaces the cache. ETag / If-None-Match is used automatically; a 304 Not Modified resets the TTL without downloading data. Rarely needed - the SDK syncs automatically.

Metadata

fn key_type(&self) -> &str

"sk", "pk", or "" (when authentication is exclusively via WIF with no static key set).

fn kind(&self) -> String

The service kind reported by the backend: "backend", "frontend", or "" if not yet determined.

fn synced_at(&self) -> Option<Instant>

Instant of the last successful sync, or None before the first sync completes.

fn billing_overdue(&self) -> bool

true when the most recent sync returned HTTP 402. While set, background refresh is suspended and the last cached snapshot is served.

Structs

NexusConfig

WifConfig

NexusError enum

Use match on variants. NexusError implements std::error::Error and Display. See Error handling for when each variant is returned.