pub struct Client { /* private fields */ }
Expand description

A client for the LaunchDarkly API.

In order to create a client instance you must first create a crate::Config.

Examples

Creating a client, with default configuration.

    let ld_client = Client::build(ConfigBuilder::new("sdk-key").build())?;

Creating an instance which connects to a relay proxy.

    let ld_client = Client::build(ConfigBuilder::new("sdk-key")
        .service_endpoints(ServiceEndpointsBuilder::new()
            .relay_proxy("http://my-relay-hostname:8080")
        ).build()
    )?;

Each builder type includes usage examples for the builder.

Implementations

Create a new instance of a Client based on the provided Config parameter.

Starts a client in the current thread, which must have a default tokio runtime.

Creates a new tokio runtime and then starts the client. Tasks from the client will be executed on created runtime. If your application already has a tokio runtime, then you can use crate::Client::start_with_default_executor and the client will dispatch tasks to your existing runtime.

This is an async method that will resolve once initialization is complete. Initialization being complete does not mean that initialization was a success. The return value from the method indicates if the client successfully initialized.

This function synchronously returns if the SDK is initialized. In the case of unrecoverable errors in establishing a connection it is possible for the SDK to never become initialized.

Close shuts down the LaunchDarkly client. After calling this, the LaunchDarkly client should no longer be used. The method will block until all pending analytics events (if any) been sent.

Flush tells the client that all pending analytics events (if any) should be delivered as soon as possible. Flushing is asynchronous, so this method will return before it is complete. However, if you call Client::close, events are guaranteed to be sent before that method returns.

For more information, see the Reference Guide: https://docs.launchdarkly.com/sdk/features/flush#rust.

Identify reports details about a user.

For more information, see the Reference Guide: https://docs.launchdarkly.com/sdk/features/identify#rust

Alias associates two users for analytics purposes.

This can be helpful in the situation where a person is represented by multiple LaunchDarkly users. This may happen, for example, when a person initially logs into an application– the person might be represented by an anonymous user prior to logging in and a different user after logging in, as denoted by a different user key.

For more information, see the Reference Guide: https://docs.launchdarkly.com/sdk/features/aliasing-users#rust.

Returns the value of a boolean feature flag for a given user.

Returns default if there is an error, if the flag doesn’t exist, or the feature is turned off and has no off variation.

For more information, see the Reference Guide: https://docs.launchdarkly.com/sdk/features/evaluating#rust.

Returns the value of a string feature flag for a given user.

Returns default if there is an error, if the flag doesn’t exist, or the feature is turned off and has no off variation.

For more information, see the Reference Guide: https://docs.launchdarkly.com/sdk/features/evaluating#rust.

Returns the value of a float feature flag for a given user.

Returns default if there is an error, if the flag doesn’t exist, or the feature is turned off and has no off variation.

For more information, see the Reference Guide: https://docs.launchdarkly.com/sdk/features/evaluating#rust.

Returns the value of a integer feature flag for a given user.

Returns default if there is an error, if the flag doesn’t exist, or the feature is turned off and has no off variation.

For more information, see the Reference Guide: https://docs.launchdarkly.com/sdk/features/evaluating#rust.

Returns the value of a feature flag for the given user, allowing the value to be of any JSON type.

The value is returned as an serde_json::Value.

Returns default if there is an error, if the flag doesn’t exist, or the feature is turned off.

For more information, see the Reference Guide: https://docs.launchdarkly.com/sdk/features/evaluating#rust.

This method is the same as Client::bool_variation, but also returns further information about how the value was calculated. The “reason” data will also be included in analytics events.

For more information, see the Reference Guide: https://docs.launchdarkly.com/sdk/features/evaluation-reasons#rust.

This method is the same as Client::str_variation, but also returns further information about how the value was calculated. The “reason” data will also be included in analytics events.

For more information, see the Reference Guide: https://docs.launchdarkly.com/sdk/features/evaluation-reasons#rust.

This method is the same as Client::float_variation, but also returns further information about how the value was calculated. The “reason” data will also be included in analytics events.

For more information, see the Reference Guide: https://docs.launchdarkly.com/sdk/features/evaluation-reasons#rust.

This method is the same as Client::int_variation, but also returns further information about how the value was calculated. The “reason” data will also be included in analytics events.

For more information, see the Reference Guide: https://docs.launchdarkly.com/sdk/features/evaluation-reasons#rust.

This method is the same as Client::json_variation, but also returns further information about how the value was calculated. The “reason” data will also be included in analytics events.

For more information, see the Reference Guide: https://docs.launchdarkly.com/sdk/features/evaluation-reasons#rust.

Generates the secure mode hash value for a user.

For more information, see the Reference Guide: https://docs.launchdarkly.com/sdk/features/secure-mode#rust.

Returns an object that encapsulates the state of all feature flags for a given user. This includes the flag values, and also metadata that can be used on the front end.

The most common use case for this method is to bootstrap a set of client-side feature flags from a back-end service.

You may pass any configuration of FlagDetailConfig to control what data is included.

For more information, see the Reference Guide: https://docs.launchdarkly.com/sdk/features/all-flags#rust

This method is the same as Client::variation, but also returns further information about how the value was calculated. The “reason” data will also be included in analytics events.

For more information, see the Reference Guide: https://docs.launchdarkly.com/sdk/features/evaluation-reasons#rust.

This is a generic function which returns the value of a feature flag for a given user.

This method is an alternatively to the type specified methods (e.g. Client::bool_variation, Client::int_variation, etc.).

Returns default if there is an error, if the flag doesn’t exist, or the feature is turned off and has no off variation.

For more information, see the Reference Guide: https://docs.launchdarkly.com/sdk/features/evaluating#rust.

Reports that a user has performed an event.

The key parameter is defined by the application and will be shown in analytics reports; it normally corresponds to the event name of a metric that you have created through the LaunchDarkly dashboard. If you want to associate additional data with this event, use Client::track_data or Client::track_metric.

For more information, see the Reference Guide: https://docs.launchdarkly.com/sdk/features/events#rust.

Reports that a user has performed an event, and associates it with custom data.

The key parameter is defined by the application and will be shown in analytics reports; it normally corresponds to the event name of a metric that you have created through the LaunchDarkly dashboard.

data parameter is any type that implements Serialize. If no such value is needed, use serde_json::Value::Null (or call Client::track_event instead). To send a numeric value for experimentation, use Client::track_metric.

For more information, see the Reference Guide: https://docs.launchdarkly.com/sdk/features/events#rust.

Reports that a user has performed an event, and associates it with a numeric value. This value is used by the LaunchDarkly experimentation feature in numeric custom metrics, and will also be returned as part of the custom event for Data Export.

The key parameter is defined by the application and will be shown in analytics reports; it normally corresponds to the event name of a metric that you have created through the LaunchDarkly dashboard.

For more information, see the Reference Guide: https://docs.launchdarkly.com/sdk/features/events#rust.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more