pub struct Detail<T> {
    pub value: Option<T>,
    pub variation_index: Option<VariationIndex>,
    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<VariationIndex>

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§

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.

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.

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

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

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

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.

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.

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§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

Should always be Self
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.