#![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_setZfsArcValues;
#[cfg(not(target_os = "macos"))]
use crate::ported::linux::platform::Platform_setZfsArcValues;
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_writeAscii};
static ZfsArcMeter_attributes: [i32; 5] = [
ColorElements::ZFS_MFU as i32,
ColorElements::ZFS_MRU as i32,
ColorElements::ZFS_ANON as i32,
ColorElements::ZFS_HEADER as i32,
ColorElements::ZFS_OTHER as i32,
];
pub fn ZfsArcMeter_readStats(this: &mut Meter, stats: &ZfsArcStats) {
this.total = stats.max as f64;
this.values[0] = stats.MFU as f64;
this.values[1] = stats.MRU as f64;
this.values[2] = stats.anon as f64;
this.values[3] = stats.header as f64;
this.values[4] = stats.other as f64;
this.curItems = 5;
this.values[5] = stats.size as f64;
}
pub fn ZfsArcMeter_updateValues(this: &mut Meter) {
Platform_setZfsArcValues(this);
this.txtBuffer = format!(
"{}/{}",
Meter_humanUnit(this.values[5]),
Meter_humanUnit(this.total)
);
}
pub fn ZfsArcMeter_display(this: &Meter, out: &mut RichString) {
let scheme = ColorScheme::active();
if this.values[5] > 0.0 {
let buffer = Meter_humanUnit(this.total);
RichString_appendAscii(
out,
ColorElements::METER_VALUE.packed(scheme),
buffer.as_bytes(),
);
let buffer = Meter_humanUnit(this.values[5]);
RichString_appendAscii(out, ColorElements::METER_TEXT.packed(scheme), b" Used:");
RichString_appendAscii(
out,
ColorElements::METER_VALUE.packed(scheme),
buffer.as_bytes(),
);
let buffer = Meter_humanUnit(this.values[0]);
RichString_appendAscii(out, ColorElements::METER_TEXT.packed(scheme), b" MFU:");
RichString_appendAscii(
out,
ColorElements::ZFS_MFU.packed(scheme),
buffer.as_bytes(),
);
let buffer = Meter_humanUnit(this.values[1]);
RichString_appendAscii(out, ColorElements::METER_TEXT.packed(scheme), b" MRU:");
RichString_appendAscii(
out,
ColorElements::ZFS_MRU.packed(scheme),
buffer.as_bytes(),
);
let buffer = Meter_humanUnit(this.values[2]);
RichString_appendAscii(out, ColorElements::METER_TEXT.packed(scheme), b" Anon:");
RichString_appendAscii(
out,
ColorElements::ZFS_ANON.packed(scheme),
buffer.as_bytes(),
);
let buffer = Meter_humanUnit(this.values[3]);
RichString_appendAscii(out, ColorElements::METER_TEXT.packed(scheme), b" Hdr:");
RichString_appendAscii(
out,
ColorElements::ZFS_HEADER.packed(scheme),
buffer.as_bytes(),
);
let buffer = Meter_humanUnit(this.values[4]);
RichString_appendAscii(out, ColorElements::METER_TEXT.packed(scheme), b" Oth:");
RichString_appendAscii(
out,
ColorElements::ZFS_OTHER.packed(scheme),
buffer.as_bytes(),
);
} else {
RichString_writeAscii(out, ColorElements::METER_TEXT.packed(scheme), b" ");
RichString_appendAscii(
out,
ColorElements::FAILED_READ.packed(scheme),
b"Unavailable",
);
}
}
pub static ZfsArcMeter_class: MeterClass = MeterClass {
super_: ObjectClass {
extends: Some(&Meter_class.super_),
},
display: Some(ZfsArcMeter_display),
init: None,
done: None,
updateMode: None,
updateValues: Some(ZfsArcMeter_updateValues),
draw: None,
getCaption: None,
getUiName: None,
defaultMode: TEXT_METERMODE,
supportedModes: METERMODE_DEFAULT_SUPPORTED,
total: 100.0,
attributes: &ZfsArcMeter_attributes,
name: "ZFSARC",
uiName: "ZFS ARC",
caption: "ARC: ",
description: None,
maxItems: 6,
isMultiColumn: false,
isPercentChart: true,
};