Struct launchdarkly_server_sdk::Detail

source ·
pub struct Detail<T> {
    pub value: Option<T>,
    pub variation_index: Option<isize>,
    pub reason: Reason,
}
Expand description

A Detail instance is returned from evaluate, combining the result of a flag evaluation with an explanation of how it was calculated.

Fields§

§value: Option<T>

The result of the flag evaluation. This will be either one of the flag’s variations or None if no appropriate fallback value was configured.

§variation_index: Option<isize>

The index of the returned value within the flag’s list of variations, e.g. 0 for the first variation. This is an Option because it is possible for the value to be undefined (there is no variation index if the application default value was returned due to an error in evaluation) which is different from a value of 0.

§reason: Reason

A reason struct describing the main factor that influenced the flag evaluation value.

Implementations§

source§

impl<T> Detail<T>

source

pub fn empty(reason: Reason) -> Detail<T>

Returns a detail with value and variation_index of None.

If a flag does not have an appropriate fallback value, the Detail::value and Detail::variation_index must be None. In each case, the Detail::reason will be set to the reason provided to this method.

source

pub fn err_default(error: Error, default: T) -> Detail<T>

Returns a detail response using the provided default as the value and a variation_index of None.

If the SDK variation methods detect some error condition, it will fallback to the user-provided default value. The provided error will be included as part of the Detail::reason, and the Detail::variation_index will be set to None.

source

pub fn err(error: Error) -> Detail<T>

Returns a detail response using the provided error as the Detail::reason.

source

pub fn map<U, F>(self, f: F) -> Detail<U>
where F: FnOnce(T) -> U,

Returns a new instance of this detail with the provided function f applied to Detail::value.

source

pub fn should_have_value(self, e: Error) -> Detail<T>

Sets the Detail::reason to the provided error if the current detail instance does not have a value set.

source

pub fn try_map<U, F>(self, f: F, default: U, e: Error) -> Detail<U>
where F: FnOnce(T) -> Option<U>,

Returns a new instance of detail with the provided function f applied to Detail::value if it exists.

Detail::value may or may not be set. If it is not set, this method will return a new Detail instance with the Detail::reason set to the provided Error e.

If it is set, this method will apply the provided function f to the value. If the method f returns None, this method will return an error Detail. See Detail::err. Otherwise, a Detail instance will be returned with the result of the f application.

source

pub fn or(self, default: T) -> Detail<T>

Set the Detail::value to default if it does not exist.

The SDK always wants to return an evaluation result. This method helps ensure that if a Detail::value is None, we can update it with the provided default.

source

pub fn or_else<F>(self, default: F) -> Detail<T>
where F: Fn() -> T,

Set the Detail::value to default if it does not exist.

This method accomplishes the same thing as Detail::or but allows the default value to be provided through the result of a callback. This helps reduce computation where an evaluation default value might be costly to calculate and is likely infrequently used.

Trait Implementations§

source§

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

source§

fn clone(&self) -> Detail<T>

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

source§

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

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

impl<T> PartialEq for Detail<T>
where T: PartialEq,

source§

fn eq(&self, other: &Detail<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T> StructuralPartialEq for Detail<T>

Auto Trait Implementations§

§

impl<T> Freeze for Detail<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for Detail<T>
where T: RefUnwindSafe,

§

impl<T> Send for Detail<T>
where T: Send,

§

impl<T> Sync for Detail<T>
where T: Sync,

§

impl<T> Unpin for Detail<T>
where T: Unpin,

§

impl<T> UnwindSafe for Detail<T>
where T: UnwindSafe,

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

source§

default unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

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

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same for T

§

type Output = T

Should always be Self
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.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

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

fn with_current_subscriber(self) -> WithDispatch<Self>

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