feat: add compact versions of bandwidthBytes to network module

Adds the following:
- bandwidthDownByesCompact
- bandwidthUpByesCompact

Differences from normal version:
- drop the "/s" suffix
- drop the deciaml part if less than 1MB/s
This commit is contained in:
Yui
2026-05-01 22:31:03 +03:00
parent cca8dc38b6
commit c81a039a55
2 changed files with 13 additions and 3 deletions
+5 -3
View File
@@ -5,12 +5,13 @@
class pow_format {
public:
pow_format(long long val, std::string&& unit, bool binary = false)
: val_(val), unit_(unit), binary_(binary) {};
pow_format(long long val, std::string&& unit, bool binary = false, int min_pow_for_decimal = 0)
: val_(val), unit_(unit), binary_(binary), min_pow_for_decimal_(min_pow_for_decimal) {};
long long val_;
std::string unit_;
bool binary_;
int min_pow_for_decimal_;
};
namespace fmt {
@@ -74,7 +75,8 @@ struct formatter<pow_format> {
break;
case 0:
default:
format = "{coefficient:.1f}{prefix}{unit}";
format = pow < s.min_pow_for_decimal_ ? "{coefficient:.0f}{prefix}{unit}"
: "{coefficient:.1f}{prefix}{unit}";
break;
}
return fmt::format_to(