8#include <userver/formats/serialize/to.hpp>
10USERVER_NAMESPACE_BEGIN
12namespace utils::statistics {
18 using ValueType = std::uint64_t;
22 inline Rate& operator+=(
Rate other)
noexcept {
27 explicit operator
bool()
const noexcept {
return value != 0; }
29 bool operator==(
const Rate& rhs)
const noexcept {
return value == rhs.value; }
31 bool operator!=(
const Rate& rhs)
const noexcept {
return !(*
this == rhs); }
33 bool operator<(
const Rate& rhs)
const noexcept {
return value < rhs.value; }
35 bool operator>(
const Rate& rhs)
const noexcept {
return rhs < *
this; }
37 bool operator<=(
const Rate& rhs)
const noexcept {
return !(rhs < *
this); }
39 bool operator>=(
const Rate& rhs)
const noexcept {
return !(*
this < rhs); }
43 return Rate{first.value + second.value};
46template <
typename ValueType>
47ValueType Serialize(
const Rate& rate,
48 USERVER_NAMESPACE::formats::
serialize::
To<ValueType>) {
49 using ValueBuilder =
typename ValueType::Builder;
50 return ValueBuilder{rate.value}.ExtractValue();