> For the complete documentation index, see [llms.txt](https://docs.winga.me/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.winga.me/integrations/rust.md).

# Rust

There is no dedicated Winga SDK for Rust. Use the [Evaluation API](/api-reference/evaluation-api.md) directly with `reqwest` and `serde`. Load the flag map once, then read it.

```rust
use std::collections::HashMap;
use serde::Deserialize;

#[derive(Deserialize)]
struct FlagState {
    enabled: bool,
}

#[derive(Deserialize)]
struct FlagsResponse {
    flags: HashMap<String, FlagState>,
}

pub struct Winga {
    flags: HashMap<String, FlagState>,
}

impl Winga {
    pub async fn load(api_key: &str, environment: &str) -> reqwest::Result<Self> {
        let url = format!("https://api.winga.me/v1/flags?env={environment}");
        let resp: FlagsResponse = reqwest::Client::new()
            .get(url)
            .header("X-Winga-Key", api_key)
            .send()
            .await?
            .json()
            .await?;
        Ok(Self { flags: resp.flags })
    }

    pub fn is_enabled(&self, key: &str) -> bool {
        self.flags.get(key).map(|f| f.enabled).unwrap_or(false)
    }
}
```

```rust
// Usage
let ff = Winga::load("proj_live_xxx", "production").await?;

if ff.is_enabled("new-checkout") {
    // ...
}
```

For realtime updates, consume the `GET /v1/stream?env=<environment>` SSE response and re-parse the flag map on each `data:` frame.
