1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// Copyright 2022 Twitter, Inc.
// Licensed under the Apache License, Version 2.0
// http://www.apache.org/licenses/LICENSE-2.0

/// A `Bucket` represents a discrete range of values and the sum of recorded
/// counts within this range.
#[derive(Clone, Copy)]
pub struct Bucket {
    pub(crate) low: u64,
    pub(crate) high: u64,
    pub(crate) count: u32,
}

impl Bucket {
    /// The lowest value represented by this `Bucket`.
    pub fn low(&self) -> u64 {
        self.low
    }

    /// The highest value represented by this `Bucket`.
    pub fn high(&self) -> u64 {
        self.high
    }

    /// The sum of the recorded counts which fall into this `Bucket`.
    pub fn count(&self) -> u32 {
        self.count
    }
}