Struct vexilla_client::VexillaClient

source ·
pub struct VexillaClient { /* private fields */ }
Expand description

VexillaClient is the core struct of this SDK. Most interaction with Vexilla and your feature flags will be through this struct.

Implementations§

source§

impl VexillaClient

source

pub fn new( environment: impl Into<&'static str>, base_url: impl Into<&'static str>, instance_id: impl Into<&'static str> ) -> VexillaClient

Create a new client for consuming feature flags.

source

pub fn get_manifest( &self, fetch: fn(url: &str) -> Result<String, VexillaError> ) -> Result<Manifest, VexillaError>

Fetches the manifest file for facilitating name->id lookups. Does not set the value on the client. You would need to call set_manifest after. Alternatively, you can use sync_manifest to do both steps with less code.

source

pub fn set_manifest(&mut self, manifest: Manifest)

Sets a fetched manifest within the VexillaClient instance. It can also be useful for mocking flags for testing.

source

pub fn sync_manifest( &mut self, fetch: fn(url: &str) -> Result<String, VexillaError> ) -> Result<bool, VexillaError>

Fetches and sets the manifest within the client to facilitate name->Id lookups.

source

pub fn get_flags( &self, group_name_or_id: &str, fetch: fn(url: &str) -> Result<String, VexillaError> ) -> Result<FlagGroup, VexillaError>

Fetches the flags for a specific flag group. Can use the ID or the name of the group for the lookup.

source

pub fn set_flags(&mut self, flags: FlagGroup) -> Result<bool, VexillaError>

Sets a fetched flag group within the Client instance.

source

pub fn sync_flags( &mut self, group_name_or_id: &str, fetch: fn(url: &str) -> Result<String, VexillaError> ) -> Result<(), VexillaError>

Fetches and sets the flag group within the client to facilitate name->Id lookups.

source

pub fn should( &self, group_name_or_id: &'static str, feature_name_or_id: impl Into<&'static str> ) -> Result<bool, VexillaError>

Checks if a toggle, gradual, or selective flag should be enabled. Other methods exist for other flag types, such as value.

source

pub fn should_custom_str( &self, group_name_or_id: &str, feature_name_or_id: impl Into<&'static str>, custom_id: &str ) -> Result<bool, VexillaError>

Checks if a toggle, gradual, or selective flag should be enabled. Uses a custom instance ID rather than the one set in the Client. Other methods exist for other flag types, such as value.

source

pub fn should_custom_int( &self, group_name_or_id: &str, feature_name_or_id: impl Into<&'static str>, custom_id: i64 ) -> Result<bool, VexillaError>

Checks if a toggle, gradual, or selective flag should be enabled. Uses a custom instance ID rather than the one set in the Client. Other methods exist for other flag types, such as value.

source

pub fn should_custom_float( &self, group_name_or_id: &str, feature_name_or_id: impl Into<&'static str>, custom_id: f64 ) -> Result<bool, VexillaError>

Checks if a toggle, gradual, or selective flag should be enabled. Uses a custom instance ID rather than the one set in the Client. Other methods exist for other flag types, such as value.

source

pub fn value_str( &self, group_name_or_id: &str, feature_name_or_id: impl Into<&'static str>, default: &'static str ) -> Result<String, VexillaError>

Gets an environment specific string value and falls back to a default if the feature is outside of its schedule.

source

pub fn value_int( &self, group_name_or_id: &str, feature_name_or_id: impl Into<&'static str>, default: i64 ) -> Result<i64, VexillaError>

Gets an environment specific int value and falls back to a default if the feature is outside of its schedule.

source

pub fn value_float( &self, group_name_or_id: &str, feature_name_or_id: impl Into<&'static str>, default: f64 ) -> Result<f64, VexillaError>

Gets an environment specific float value and falls back to a default if the feature is outside of its schedule.

Trait Implementations§

source§

impl Clone for VexillaClient

source§

fn clone(&self) -> VexillaClient

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for VexillaClient

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for VexillaClient

source§

fn default() -> VexillaClient

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.