1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// SPDX-FileCopyrightText: Copyright (c) 2026 Mike Li/Mikewolfli/Wei Li(mikewolfli@163.com)
// SPDX-License-Identifier: MIT
//! Runs the unified platform diagnostic probe on this host.
//!
//! This is the desktop harness for BLUE28 B28.01. It prints the stable JSON form, one line per
//! fact, and a final `RESULT: PASS` / `RESULT: FAIL` line. A fact this backend honestly does not
//! have is reported as `skip` and does not fail the run.
//!
//! Run with:
//!
//! ```text
//! cargo run --example platform_diagnostics
//! ```
//!
//! The same probe is reachable from C as `rw_platform_diagnostics()` (mask) and
//! `rw_platform_diagnostics_json()` (this JSON), and from Android through
//! `nativePlatformProbe`.
fn main() {
rust_widgets::init();
let diagnostics = rust_widgets::platform::diagnostics::run();
println!("{}", diagnostics.to_json());
for entry in &diagnostics.entries {
println!(
"bit {:>2} {:<20} {:<5} {}",
entry.bit,
entry.name,
entry.status.as_str(),
entry.detail
);
}
println!("{}", diagnostics.summary());
println!(
"host: dpi_scale_factor={} displays={:?}",
rust_widgets::platform::dpi_scale_factor(),
rust_widgets::platform::displays()
);
let environment = rust_widgets::style::EnvironmentSnapshot::from_provider(
&rust_widgets::style::environment::PlatformEnvironment,
);
println!(
"environment: locale={:?} direction={:?} contrast={} motion={:?} theme={:?}",
environment.locale,
environment.text_direction,
environment.high_contrast,
environment.motion_preference,
environment.color_scheme
);
println!(
"system_fonts: {} families (first 3: {:?})",
rust_widgets::platform::get_platform().system_fonts().len(),
rust_widgets::platform::get_platform()
.system_fonts()
.iter()
.take(3)
.map(|font| font.family.clone())
.collect::<Vec<_>>()
);
if diagnostics.is_pass() {
println!("RESULT: PASS");
} else {
println!("RESULT: FAIL");
std::process::exit(1);
}
}