@@ -225,6 +225,15 @@ impl From<f64> for HistogramPoints {
225
225
}
226
226
}
227
227
228
+ impl From < ( u64 , f64 ) > for HistogramPoints {
229
+ fn from ( ( ts, value) : ( u64 , f64 ) ) -> Self {
230
+ let mut histogram = Histogram :: default ( ) ;
231
+ histogram. insert ( value, SampleRate :: unsampled ( ) ) ;
232
+
233
+ Self ( TimestampedValue :: from ( ( ts, histogram) ) . into ( ) )
234
+ }
235
+ }
236
+
228
237
impl < const N : usize > From < [ f64 ; N ] > for HistogramPoints {
229
238
fn from ( values : [ f64 ; N ] ) -> Self {
230
239
let mut histogram = Histogram :: default ( ) ;
@@ -236,6 +245,33 @@ impl<const N: usize> From<[f64; N]> for HistogramPoints {
236
245
}
237
246
}
238
247
248
+ impl < const N : usize > From < ( u64 , [ f64 ; N ] ) > for HistogramPoints {
249
+ fn from ( ( ts, values) : ( u64 , [ f64 ; N ] ) ) -> Self {
250
+ let mut histogram = Histogram :: default ( ) ;
251
+ for value in values {
252
+ histogram. insert ( value, SampleRate :: unsampled ( ) ) ;
253
+ }
254
+
255
+ Self ( TimestampedValue :: from ( ( ts, histogram) ) . into ( ) )
256
+ }
257
+ }
258
+
259
+ impl < const N : usize > From < [ ( u64 , f64 ) ; N ] > for HistogramPoints {
260
+ fn from ( values : [ ( u64 , f64 ) ; N ] ) -> Self {
261
+ Self (
262
+ values
263
+ . into_iter ( )
264
+ . map ( |( ts, value) | {
265
+ let mut histogram = Histogram :: default ( ) ;
266
+ histogram. insert ( value, SampleRate :: unsampled ( ) ) ;
267
+
268
+ ( ts, histogram)
269
+ } )
270
+ . into ( ) ,
271
+ )
272
+ }
273
+ }
274
+
239
275
impl < ' a > From < & ' a [ f64 ] > for HistogramPoints {
240
276
fn from ( values : & ' a [ f64 ] ) -> Self {
241
277
let mut histogram = Histogram :: default ( ) ;
0 commit comments