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
impl VexillaClient
sourcepub fn new(
environment: impl Into<&'static str>,
base_url: impl Into<&'static str>,
instance_id: impl Into<&'static str>
) -> VexillaClient
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.
sourcepub fn get_manifest(
&self,
fetch: fn(url: &str) -> Result<String, VexillaError>
) -> Result<Manifest, VexillaError>
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.
sourcepub fn set_manifest(&mut self, manifest: Manifest)
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.
sourcepub fn sync_manifest(
&mut self,
fetch: fn(url: &str) -> Result<String, VexillaError>
) -> Result<bool, VexillaError>
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.
sourcepub fn get_flags(
&self,
group_name_or_id: &str,
fetch: fn(url: &str) -> Result<String, VexillaError>
) -> Result<FlagGroup, VexillaError>
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.
sourcepub fn set_flags(&mut self, flags: FlagGroup) -> Result<bool, VexillaError>
pub fn set_flags(&mut self, flags: FlagGroup) -> Result<bool, VexillaError>
Sets a fetched flag group within the Client instance.
sourcepub fn sync_flags(
&mut self,
group_name_or_id: &str,
fetch: fn(url: &str) -> Result<String, VexillaError>
) -> Result<(), VexillaError>
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.
sourcepub fn should(
&self,
group_name_or_id: &'static str,
feature_name_or_id: impl Into<&'static str>
) -> Result<bool, VexillaError>
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.
sourcepub fn should_custom_str(
&self,
group_name_or_id: &str,
feature_name_or_id: impl Into<&'static str>,
custom_id: &str
) -> Result<bool, VexillaError>
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.
sourcepub fn should_custom_int(
&self,
group_name_or_id: &str,
feature_name_or_id: impl Into<&'static str>,
custom_id: i64
) -> Result<bool, VexillaError>
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.
sourcepub fn should_custom_float(
&self,
group_name_or_id: &str,
feature_name_or_id: impl Into<&'static str>,
custom_id: f64
) -> Result<bool, VexillaError>
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.
sourcepub fn value_str(
&self,
group_name_or_id: &str,
feature_name_or_id: impl Into<&'static str>,
default: &'static str
) -> Result<String, VexillaError>
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.
Trait Implementations§
source§impl Clone for VexillaClient
impl Clone for VexillaClient
source§fn clone(&self) -> VexillaClient
fn clone(&self) -> VexillaClient
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more