pub struct DownloadAcceleration { /* private fields */ }Expand description
Download acceleration in bytes per second squared
下载加速度(单位:字节每秒平方)
Implementations§
Source§impl DownloadAcceleration
impl DownloadAcceleration
Sourcepub fn from_raw(bytes_per_second_sq: i64, standard: SizeStandard) -> Self
pub fn from_raw(bytes_per_second_sq: i64, standard: SizeStandard) -> Self
Create a new download acceleration from raw bytes per second squared
§Parameters
bytes_per_second_sq: Non-zero acceleration in bytes per second squaredstandard: Standard to use (SI or IEC)
§Note
For negative acceleration, use as u64 conversion of i64 to ensure proper sign handling
从原始字节/秒²创建一个新的下载加速度实例
§参数
bytes_per_second_sq: 非零的字节/秒²加速度值standard: 使用的标准(SI 或 IEC)
§注意
对于负加速度,使用 i64 的 as u64 转换,确保正确处理符号位
Sourcepub fn new(
initial_speed: NonZeroU64,
final_speed: NonZeroU64,
duration: Duration,
standard: SizeStandard,
) -> Self
pub fn new( initial_speed: NonZeroU64, final_speed: NonZeroU64, duration: Duration, standard: SizeStandard, ) -> Self
Create a new download acceleration from speed change and time interval
§Parameters
initial_speed: Initial speed in non-zero bytes per secondfinal_speed: Final speed in non-zero bytes per secondduration: Time interval for the speed changestandard: Standard to use (SI or IEC)
§Panics
Panics if initial_speed or final_speed is zero
从下载速度变化量和时间间隔创建一个新的下载加速度实例
§参数
initial_speed: 初始速度(非零字节/秒)final_speed: 最终速度(非零字节/秒)duration: 速度变化所用的时间standard: 使用的标准(SI 或 IEC)
§Panics
如果 initial_speed 或 final_speed 为零,此函数会 panic。
Sourcepub fn as_decimal(&self) -> Decimal
pub fn as_decimal(&self) -> Decimal
Get the acceleration in bytes per second squared as a Decimal
以 Decimal 的形式获取字节每秒平方
Sourcepub fn as_i64(&self) -> i64
pub fn as_i64(&self) -> i64
Get the acceleration in bytes per second squared as i64 (floored)
以 i64 的形式获取字节每秒平方(向下取整)
Sourcepub fn get_si_parts(&self) -> (String, &'static str)
pub fn get_si_parts(&self) -> (String, &'static str)
Returns the formatted value and unit in SI (base-1000) standard
返回 SI (base-1000) 标准的 (formatted_value, unit)
Sourcepub fn get_iec_parts(&self) -> (String, &'static str)
pub fn get_iec_parts(&self) -> (String, &'static str)
Returns the formatted value and unit in IEC (base-1024) standard
返回 IEC (base-1024) 标准的 (formatted_value, unit)
Trait Implementations§
Source§impl Clone for DownloadAcceleration
impl Clone for DownloadAcceleration
Source§fn clone(&self) -> DownloadAcceleration
fn clone(&self) -> DownloadAcceleration
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more