MCPcopy Create free account
hub / github.com/FeatureProbe/server-sdk-rust / select_variation

Method select_variation

src/evaluate.rs:28–47  ·  view source on GitHub ↗
(&self, eval_param: &EvalParams)

Source from the content-addressed store, hash-verified

26
27impl Serve {
28 pub fn select_variation(&self, eval_param: &EvalParams) -> Result<Variation, FPError> {
29 let variations = eval_param.variations;
30 let index = match self {
31 Serve::Select(i) => *i,
32 Serve::Split(distribution) => distribution.find_index(eval_param)?,
33 };
34
35 match variations.get(index) {
36 None if eval_param.is_detail => Err(FPError::EvalDetailError(format!(
37 "index {} overflow, variations count is {}",
38 index,
39 variations.len()
40 ))),
41 None => Err(FPError::EvalError),
42 Some(v) => Ok(Variation {
43 value: v.clone(),
44 index,
45 }),
46 }
47 }
48}
49
50#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Clone)]

Callers 3

fixed_variationMethod · 0.80
serve_variationMethod · 0.80

Calls 2

find_indexMethod · 0.80
getMethod · 0.80

Tested by 1