Struct Client

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

The OpenFeature client. Create it through the [OpenFeature] struct.

Implementations§

Source§

impl Client

Source

pub fn new( name: impl Into<String>, global_evaluation_context: GlobalEvaluationContext, global_hooks: GlobalHooks, provider_registry: ProviderRegistry, ) -> Self

Create a new Client instance.

Source

pub fn metadata(&self) -> &ClientMetadata

Return the metadata of current client.

Source

pub fn set_evaluation_context(&mut self, evaluation_context: EvaluationContext)

Set evaluation context to the client.

Source

pub async fn get_bool_value( &self, flag_key: &str, evaluation_context: Option<&EvaluationContext>, evaluation_options: Option<&EvaluationOptions>, ) -> EvaluationResult<bool>

Evaluate given flag_key with corresponding evaluation_context and evaluation_options as a bool value.

Source

pub async fn get_int_value( &self, flag_key: &str, evaluation_context: Option<&EvaluationContext>, evaluation_options: Option<&EvaluationOptions>, ) -> EvaluationResult<i64>

Evaluate given flag_key with corresponding evaluation_context and evaluation_options as an int (i64) value.

Source

pub async fn get_float_value( &self, flag_key: &str, evaluation_context: Option<&EvaluationContext>, evaluation_options: Option<&EvaluationOptions>, ) -> EvaluationResult<f64>

Evaluate given flag_key with corresponding evaluation_context and evaluation_options as a float (f64) value. If the resolution fails, the default_value is returned.

Source

pub async fn get_string_value( &self, flag_key: &str, evaluation_context: Option<&EvaluationContext>, evaluation_options: Option<&EvaluationOptions>, ) -> EvaluationResult<String>

Evaluate given flag_key with corresponding evaluation_context and evaluation_options as a string value. If the resolution fails, the default_value is returned.

Source

pub async fn get_struct_value<T: TryFrom<StructValue>>( &self, flag_key: &str, evaluation_context: Option<&EvaluationContext>, evaluation_options: Option<&EvaluationOptions>, ) -> EvaluationResult<T>

Evaluate given flag_key with corresponding evaluation_context and evaluation_options as a struct. If the resolution fails, the default_value is returned. The required type should implement From<StructValue> trait.

Source

pub async fn get_bool_details( &self, flag_key: &str, evaluation_context: Option<&EvaluationContext>, evaluation_options: Option<&EvaluationOptions>, ) -> EvaluationResult<EvaluationDetails<bool>>

Return the EvaluationDetails with given flag_key, evaluation_context and evaluation_options.

Source

pub async fn get_int_details( &self, flag_key: &str, evaluation_context: Option<&EvaluationContext>, evaluation_options: Option<&EvaluationOptions>, ) -> EvaluationResult<EvaluationDetails<i64>>

Return the EvaluationDetails with given flag_key, evaluation_context and evaluation_options.

Source

pub async fn get_float_details( &self, flag_key: &str, evaluation_context: Option<&EvaluationContext>, evaluation_options: Option<&EvaluationOptions>, ) -> EvaluationResult<EvaluationDetails<f64>>

Return the EvaluationDetails with given flag_key, evaluation_context and evaluation_options.

Source

pub async fn get_string_details( &self, flag_key: &str, evaluation_context: Option<&EvaluationContext>, evaluation_options: Option<&EvaluationOptions>, ) -> EvaluationResult<EvaluationDetails<String>>

Return the EvaluationDetails with given flag_key, evaluation_context and evaluation_options.

Source

pub async fn get_struct_details<T: TryFrom<StructValue>>( &self, flag_key: &str, evaluation_context: Option<&EvaluationContext>, evaluation_options: Option<&EvaluationOptions>, ) -> EvaluationResult<EvaluationDetails<T>>

Return the EvaluationDetails with given flag_key, evaluation_context and evaluation_options.

Source§

impl Client

Source

pub fn with_hook<T: Hook>(self, hook: T) -> Self

Add a hook to the client.

Source

pub fn with_logging_hook(self, include_evaluation_context: bool) -> Self

Add logging hook to the client.

Auto Trait Implementations§

§

impl Freeze for Client

§

impl !RefUnwindSafe for Client

§

impl Send for Client

§

impl Sync for Client

§

impl Unpin for Client

§

impl !UnwindSafe for Client

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> Any for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Source§

fn type_name(&self) -> &'static str

Source§

impl<T> AnySync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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>,

Source§

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.