[][src]Struct bullettrain::Client

pub struct Client {
    pub api_key: String,
    pub base_uri: String,
}

Provides various methods to interact with BulletTrain API.

Static method new can be used to create instance configured with default API address. To use custom API address, use struct constructor.

Example

let client = bullettrain::Client {
    api_key: String::from("secret key"),
    base_uri: String::from("https://features.on.my.own.server/api/v1/"),
};

Fields

api_key: Stringbase_uri: String

Implementations

impl Client[src]

pub fn new(api_key: &str) -> Client[src]

Returns Client instance configured to use default API address and given API key.

pub fn get_features(&self) -> Result<Vec<Flag>, Error>[src]

Returns all features available in given environment.

pub fn get_user_features(&self, user: &User) -> Result<Vec<Flag>, Error>[src]

Returns all features as defined for given user.

pub fn has_feature(&self, name: &str) -> Result<bool, Error>[src]

Returns information whether given feature is defined.

pub fn has_user_feature(&self, user: &User, name: &str) -> Result<bool, Error>[src]

Returns information whether given feature is defined for given user.

pub fn feature_enabled(&self, name: &str) -> Result<bool, Error>[src]

Returns information whether given feature flag is enabled.

pub fn user_feature_enabled(
    &self,
    user: &User,
    name: &str
) -> Result<bool, Error>
[src]

Returns information whether given feature flag is enabled for given user.

pub fn get_value(&self, name: &str) -> Result<Option<Value>, Error>[src]

Returns value of given feature (remote config).

Returned value can have one of following types: boolean, integer, string.

pub fn get_user_value(
    &self,
    user: &User,
    name: &str
) -> Result<Option<Value>, Error>
[src]

Returns value of given feature (remote config) as defined for given user.

Returned value can have one of following types: boolean, integer, string.

pub fn get_trait(&self, user: &User, key: &str) -> Result<Trait, Error>[src]

Returns trait defined for given user.

pub fn get_traits(
    &self,
    user: &User,
    keys: Vec<&str>
) -> Result<Vec<Trait>, Error>
[src]

Returns all traits defined for given user.

If keys are provided, get_traits returns only corresponding traits, otherwise all traits for given user are returned.

pub fn update_trait(
    &self,
    user: &User,
    to_update: &Trait
) -> Result<Trait, Error>
[src]

Updates trait value for given user, returns updated trait.

Auto Trait Implementations

impl RefUnwindSafe for Client

impl Send for Client

impl Sync for Client

impl Unpin for Client

impl UnwindSafe for Client

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.