fn update_specific_from_json(
	elt: &mut RspamdStatElement,
	actions_json: &serde_json::Value,
	field: &[&'static str],
	elapsed: Duration,
	mult: f64,
) -> Result<f64, Box<dyn Error + Send + Sync>> {
	let total = field.iter().fold(0_u64, |acc, field| {
		let extracted = actions_json.get(field);
		let extracted = extracted.map(|v| v.as_u64().unwrap_or(0_u64));
		acc + extracted.unwrap_or(0_u64)
	}) as f64
		* mult;
	elt.update(total, elapsed)?;
	Ok(total)
}
/// Update specific counter from a JSON object, multiplying value by `mult`
Update specific counter from a JSON object, multiplying value by `mult`
Update specific counter from a JSON object multiplying value by ` mult `
fn update_specific_from_json(
	elt: &mut RspamdStatElement,
	actions_json: &serde_json::Value,
	field: &[&'static str],
	elapsed: Duration,
	mult: f64,
) -> Result<f64, Box<dyn Error + Send + Sync>> {
	let total = field.iter().fold(0_u64, |acc, field| {
		let extracted = actions_json.get(field);
		let extracted = extracted.map(|v| v.as_u64().unwrap_or(0_u64));
		acc + extracted.unwrap_or(0_u64)
	}) as f64
		* mult;
	elt.update(total, elapsed)?;
	Ok(total)
}
fn update_specific_from_json ( elt : & mut RspamdStatElement , actions_json : & serde_json :: Value , field : & [ & ' static str ] , elapsed : Duration , mult : f64 , ) -> Result < f64 , Box < dyn Error + Send + Sync > > { let total = field . iter ( ) . fold ( 0_u64 , | acc , field | { let extracted = actions_json . get ( field ) ; let extracted = extracted . map ( | v | v . as_u64 ( ) . unwrap_or ( 0_u64 ) ) ; acc + extracted . unwrap_or ( 0_u64 ) } ) as f64 * mult ; elt . update ( total , elapsed ) ? ; Ok ( total ) }
Update specific counter from a JSON object, multiplying value by `mult`
Update specific counter from a JSON object multiplying value by ` mult `
elt
&mut RspamdStatElement
actions_json
&serde_json::Value
field
&[&'static str]
elapsed
Duration
mult
f64
elt
&mut RspamdStatElement
actions_json
&serde_json::Value
field
&[&'static str]
elapsed
Duration
mult
f64