> ## Documentation Index
> Fetch the complete documentation index at: https://docs.westyx.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Rust SDK - OpenFeature

> The westyx-nexus-openfeature provider crate and its resolution mapping.

The `westyx-nexus-openfeature` crate bridges Nexus to the [OpenFeature](https://openfeature.dev) Rust SDK. The provider **wraps an existing client**: it opens no second connection and keeps no second cache, so every resolution is an in-memory read rather than a network call.

## Installation

```toml theme={null}
[dependencies]
westyx-nexus = "0.11.0-beta.2"
westyx-nexus-openfeature = "0.11.0-beta.2"
open-feature = "0.3"
```

## Usage

```rust theme={null}
use open_feature::OpenFeature;
use westyx_nexus::{NexusClient, NexusConfig};
use westyx_nexus_openfeature::NexusFeatureProvider;

let client = NexusClient::create(NexusConfig {
    api_key: std::env::var("NEXUS_API_KEY")?,
    endpoint: std::env::var("NEXUS_ENDPOINT")?,
    ..Default::default()
})
.await?;
client.run_stream(); // keeps the snapshot fresh

let mut api = OpenFeature::singleton_mut().await;
api.set_provider(NexusFeatureProvider::new(client)).await;
drop(api);

let flags = OpenFeature::singleton().await.create_client();
let enabled = flags.get_bool_value("new-checkout", None, None).await.unwrap_or(false);
```

## Resolution mapping

| OpenFeature resolution | Nexus source                                                      |
| ---------------------- | ----------------------------------------------------------------- |
| `resolve_bool_value`   | feature flag; falls back to a boolean **config** of the same name |
| `resolve_string_value` | config value, must be a string                                    |
| `resolve_int_value`    | config value, must be an integer                                  |
| `resolve_float_value`  | config value, must be a number                                    |
| `resolve_struct_value` | config value, must be a JSON object, converted recursively        |

A missing key resolves to `FlagNotFound`, and a value of the wrong shape to `TypeMismatch`. In both cases the OpenFeature SDK returns the caller's default.

Integers keep their precision: a config value of `9007199254740993` arrives as an `i64`, not a rounded float.

## Evaluation context

The evaluation context is accepted and ignored today - per-user targeting is not implemented yet, matching the other Nexus OpenFeature providers. For per-user rollouts use `evaluate_ab` on the wrapped client, reachable through `provider.client()`.

## Provider status

`status()` reports `Ready`: the wrapped client performs its initial sync during `create`, so a provider that exists can serve.

## Minimum Rust version

Rust **1.88**, the same floor as the core SDK.
