#![allow(non_snake_case)]
#![allow(non_upper_case_globals)] #![allow(dead_code)]
use crate::ported::crt::{ColorElements, ColorScheme};
use crate::ported::linux::linuxmachine::ZfsArcStats;
#[cfg(target_os = "macos")]
use crate::ported::darwin::platform::Platform_setZfsCompressedArcValues;
#[cfg(not(target_os = "macos"))]
use crate::ported::linux::platform::Platform_setZfsCompressedArcValues;
use crate::ported::meter::{
Meter, MeterClass, Meter_class, Meter_humanUnit, METERMODE_DEFAULT_SUPPORTED, TEXT_METERMODE,
};
use crate::ported::object::ObjectClass;
use crate::ported::richstring::{
RichString, RichString_appendAscii, RichString_appendnAscii, RichString_writeAscii,
};
static ZfsCompressedArcMeter_attributes: [i32; 1] = [ColorElements::ZFS_COMPRESSED as i32];
pub fn ZfsCompressedArcMeter_readStats(this: &mut Meter, stats: &ZfsArcStats) {
if stats.isCompressed != 0 {
this.total = stats.uncompressed as f64;
this.values[0] = stats.compressed as f64;
} else {
this.total = stats.size as f64;
this.values[0] = stats.size as f64;
}
}
pub fn ZfsCompressedArcMeter_printRatioString(this: &Meter) -> String {
if this.values[0] > 0.0 {
return format!("{:.2}:1", this.total / this.values[0]);
}
"N/A".to_string()
}
pub fn ZfsCompressedArcMeter_updateValues(this: &mut Meter) {
Platform_setZfsCompressedArcValues(this);
this.txtBuffer = ZfsCompressedArcMeter_printRatioString(this);
}
pub fn ZfsCompressedArcMeter_display(this: &Meter, out: &mut RichString) {
let scheme = ColorScheme::active();
if this.values[0] > 0.0 {
let buffer = Meter_humanUnit(this.total);
RichString_appendAscii(
out,
ColorElements::METER_VALUE.packed(scheme),
buffer.as_bytes(),
);
RichString_appendAscii(
out,
ColorElements::METER_TEXT.packed(scheme),
b" Uncompressed, ",
);
let buffer = Meter_humanUnit(this.values[0]);
RichString_appendAscii(
out,
ColorElements::METER_VALUE.packed(scheme),
buffer.as_bytes(),
);
RichString_appendAscii(
out,
ColorElements::METER_TEXT.packed(scheme),
b" Compressed, ",
);
let buffer = ZfsCompressedArcMeter_printRatioString(this);
let len = buffer.len();
RichString_appendnAscii(
out,
ColorElements::ZFS_RATIO.packed(scheme),
buffer.as_bytes(),
len,
);
RichString_appendAscii(out, ColorElements::METER_TEXT.packed(scheme), b" Ratio");
} else {
RichString_writeAscii(out, ColorElements::METER_TEXT.packed(scheme), b" ");
RichString_appendAscii(
out,
ColorElements::FAILED_READ.packed(scheme),
b"Compression Unavailable",
);
}
}
pub static ZfsCompressedArcMeter_class: MeterClass = MeterClass {
super_: ObjectClass {
extends: Some(&Meter_class.super_),
},
display: Some(ZfsCompressedArcMeter_display),
init: None,
done: None,
updateMode: None,
updateValues: Some(ZfsCompressedArcMeter_updateValues),
draw: None,
getCaption: None,
getUiName: None,
defaultMode: TEXT_METERMODE,
supportedModes: METERMODE_DEFAULT_SUPPORTED,
total: 100.0,
attributes: &ZfsCompressedArcMeter_attributes,
name: "ZFSCARC",
uiName: "ZFS CARC",
caption: "ARC: ",
description: Some("ZFS CARC: Compressed ARC statistics"),
maxItems: 1,
isMultiColumn: false,
isPercentChart: true,
};