Version 3 of the Rust SDK includes breaking changes. The most significant changes involve the HTTP transport layer, TLS/crypto feature flags, and some API refinements. To learn how to upgrade, read the Rust SDK 2.x to 3.0 migration guide.
Version 2 of the Rust SDK makes the rustls dependency optional. There are no changes to the SDK API.
This topic documents how to get started with the server-side Rust SDK, and links to reference information on all of the supported features.
LaunchDarkly’s SDKs are open source. In addition to this reference guide, we provide source, API reference documentation, and a sample application:
After you complete the Get started process, follow these instructions to start using the LaunchDarkly SDK in your Rust application.
First, install the LaunchDarkly SDK as a dependency in your application.
Next, import the LaunchDarkly client in your application code:
The Rust SDK uses an SDK key. Keys are specific to each project and environment. They are available on the SDK keys page under Settings. To learn more about key types, read Keys.
After you install and import the SDK, create a single, shared instance of the LaunchDarkly client. Specify your SDK key here so that your application is authorized to connect to LaunchDarkly, your application, and your environment.
Once you have created the client, start the client process and wait for the client to initialize. This SDK depends on the tokio crate to provide a default runtime and as such it is a required dependency.
Only create one instance of client.
Here’s how:
To learn more about the specific configuration options available in this SDK, read Config.
It’s important to make client a singleton for each LaunchDarkly project. The client instance maintains internal state that allows LaunchDarkly to serve feature flags without making any remote requests. Do not instantiate a new client with every request.
If you have multiple LaunchDarkly projects, you can create one LDClient for each. In this situation, the clients operate independently. For example, they do not share a single connection to LaunchDarkly.
You can use client to check which variation a particular context will receive for a given feature flag.
Here’s how:
Shut down the client when your application terminates. To learn more, read Shutting down.
This SDK supports the following features: