# Rust quickstart

## 1. Install `hypertune`

Once you have a Rust application ready, install Hypertune's Rust crate and the Serde crate:

```bash
cargo add hypertune serde
```

## 2. Install the Hypertune CLI

Run the following command to install the CLI

```
curl -fsSL https://app.hypertune.com/install-cli.sh | sh
```

Alternatively, you can download the Hypertune CLI for your system:

* [Mac (x86\_64)](https://storage.googleapis.com/public-prod-hypertune/cli/darwin_x64/hypertune)
* [Mac M1 / M2 (aarch64)](https://storage.googleapis.com/public-prod-hypertune/cli/darwin_aarch64/hypertune)
* [Linux (x86\_64)](https://storage.googleapis.com/public-prod-hypertune/cli/linux_x64/hypertune)
* [Windows (x86\_64)](https://storage.googleapis.com/public-prod-hypertune/cli/windows_x64/hypertune.exe)

Then:

* Put it somewhere accessible via your `PATH`
* Add execute permissions to it with `chmod +x hypertune`
* Right-click to open it

## 3. Generate the client

Generate a type-safe client to access your flags by running:

```bash
hypertune generate --language rust --output-file-dir src --token <token> 
```

Replace `<token>` with your main project token which you can find in the Settings tab of your project.

## 4. Use the client

```rust
mod hypertune;

fn main() {
    let root_node = hypertune::create_source(hypertune::VariableValues {}, None)
        .unwrap()
        .root(hypertune::RootArgs {
            context: hypertune::Context {
                environment: hypertune::Environment::DEVELOPMENT,
                user: hypertune::User {
                    id: "test_id".to_string(),
                    name: "Test".to_string(),
                    email: "test@test.com".to_string(),
                },
            },
        });
    root_node.wait_for_initialization();
    
    let example_flag = root_node.exampleFlag().get(false);
    
    root_node.close();
}
```

## Next steps

Now you can update the logic for `exampleFlag` from the Hypertune UI without updating your code or waiting for a new build, deployment, app release, or service restart.

To add a new flag, create it in the Hypertune UI then regenerate the client.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.hypertune.com/getting-started/rust-quickstart.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
