data_rate.go
data_rate.go - Overview
- Overview
This file defines constants for various data rate units (bits/second, bytes/second, and their multiples using both SI and IEC prefixes) and provides a converter for data rates.
- Detailed Documentation
Constants
The file defines several constants representing data rates in bits/second and bytes/second, using both base-10 (SI) and base-2 (IEC) prefixes.
- SI Prefixes (base 10):
BitPerSecond
,KilobitPerSecond
,MegabitPerSecond
,GigabitPerSecond
,TerabitPerSecond
,PetabitPerSecond
,ExabitPerSecond
,ZettabitPerSecond
,YottabitPerSecond
BytePerSecond
,KilobytePerSecond
,MegabytePerSecond
,GigabytePerSecond
,TerabytePerSecond
,PetabytePerSecond
,ExabytePerSecond
,ZettabytePerSecond
,YottabytePerSecond
- IEC Prefixes (base 2):
KibibitPerSecond
,MebibitPerSecond
,GibibitPerSecond
,TebibitPerSecond
,PebibitPerSecond
,ExbibitPerSecond
,ZebibitPerSecond
,YobibitPerSecond
KibibytePerSecond
,MebibytePerSecond
,GibibytePerSecond
,TebibytePerSecond
,PebibytePerSecond
,ExbibytePerSecond
,ZebibytePerSecond
,YobibytePerSecond
dataRateConverter
Class
Purpose:
dataRateConverter
is a struct that implements the Converter
interface for converting between different data rate units.
Methods:
-
NewDataRateConverter()
- Purpose: Creates a new instance of
dataRateConverter
. - Parameters: None
- Returns: A
Converter
interface implemented bydataRateConverter
.
- Purpose: Creates a new instance of
-
(*dataRateConverter) Name()
- Purpose: Returns the name of the converter, which is "data_rate".
- Parameters: None
- Returns: A string representing the name of the converter ("data_rate").
-
FromDataRateUnit(u Unit) float64
- Purpose: Returns the float64 value of the data rate unit based on
BitPerSecond
orBytePerSecond
. - Parameters:
u
(Unit): The data rate unit to convert from.
- Returns: A
float64
value representing the multiplier for the given unit relative toBitPerSecond
orBytePerSecond
. Returns 1 if the unit is not recognized.
- Purpose: Returns the float64 value of the data rate unit based on
-
(*dataRateConverter) Convert(v Value, to Unit) Value
- Purpose: Converts a
Value
(which contains a float and a unit) from one data rate unit to another. - Parameters:
v
(Value): The value to convert, containing the numeric value and the original unit.to
(Unit): The target unit to convert to.
- Returns: A
Value
containing the converted numeric value and the target unit.
- Purpose: Converts a
- Code Examples
Not applicable
- Clarity and Accuracy
The documentation accurately reflects the code's functionality.
- Markdown & MDX Perfection
The markdown is properly formatted and escaped.
- Edge Cases To Avoid Breaking MDX:
No issues found.
- Getting Started Relevance
Include in Getting Started: NO