libhoney/fields.rs
1use std::collections::HashMap;
2
3use crate::errors::Result;
4use crate::Value;
5
6/// `FieldHolder` implements common functions that operate on the `fields` component of a
7/// struct (usually Event or Builder). This avoids some duplication of code.
8pub trait FieldHolder {
9 /// add data to the current (event/builder) fields
10 fn add(&mut self, data: HashMap<String, Value>);
11 /// add_field adds a field to the current (event/builder) fields
12 fn add_field(&mut self, name: &str, value: Value);
13 /// add_func iterates over the results from func (until Err) and adds the results to
14 /// the event/builder fields
15 fn add_func<F>(&mut self, func: F)
16 where
17 F: Fn() -> Result<(String, Value)>;
18}