import Foundation nonisolated enum MetricFormat { static func percent(_ value: Double?) -> String { guard let value, value.isFinite else { return "--" } return "\(Int((min(1, max(0, value)) * 100).rounded()))%" } static func bytes(_ value: UInt64?) -> String { guard let value else { return "--" } return String(format: "%.1f GB", Double(value) / 1_000_000_000) } static func decimal(_ value: Double) -> String { String(format: "%.1f", value) } }