Spike, not the final UI: it answers whether flare-ui can drive Alkane OS's on-box pages, and what it costs. What works: - schema/alkane-bb.json authors the sidebar as data (3 sections, 14 tabs); - src/bin/ui-spike.rs renders it through flare_ui::nav + flare_ui::shell, so the unified sidebar, ordering and surface filtering come from the schema rather than from hand-written HTML; - the render uses the shared bf- design tokens, the same ones the rest of the suite uses. Size, measured rather than assumed (armv7, release, stripped): ui-baseline 323 KiB (maud + serde_json, no flare-ui) ui-spike 771 KiB (flare-ui + wschema + sha2) marginal 448 KiB Vendoring: third-party/flare-ui is the full v0.2.9 tree pinned in flare-ui/flare-ui.lock (a partial archive does not compile, since the crate include_str!s assets from dash-editor/). vendor/ is re-generated as a cargo directory source with the new registry dependencies (maud, sha2, typenum, digest, generic-array, block-buffer, crypto-common, cfg-if, etc.) so the build still works offline. third-party/README.md records how to re-pin.
60 lines
1.6 KiB
Rust
60 lines
1.6 KiB
Rust
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
use ciborium::{
|
|
de::{from_reader, Error},
|
|
ser::into_writer,
|
|
value::Value,
|
|
};
|
|
use rstest::rstest;
|
|
|
|
#[rstest(bytes, error,
|
|
// Invalid value
|
|
case("1e", Error::Syntax(0)),
|
|
|
|
// Indeterminate integers are invalid
|
|
case("1f", Error::Syntax(0)),
|
|
|
|
// Indeterminate integer in an array
|
|
case("83011f03", Error::Syntax(2)),
|
|
|
|
// Integer in a string continuation
|
|
case("7F616101FF", Error::Syntax(3)),
|
|
|
|
// Bytes in a string continuation
|
|
case("7F61614101FF", Error::Syntax(3)),
|
|
|
|
// Invalid UTF-8
|
|
case("62C328", Error::Syntax(0)),
|
|
|
|
// Invalid UTF-8 in a string continuation
|
|
case("7F62C328FF", Error::Syntax(1)),
|
|
)]
|
|
fn test(bytes: &str, error: Error<std::io::Error>) {
|
|
let bytes = hex::decode(bytes).unwrap();
|
|
|
|
let correct = match error {
|
|
Error::Io(..) => panic!(),
|
|
Error::Syntax(x) => ("syntax", Some(x), None),
|
|
Error::Semantic(x, y) => ("semantic", x, Some(y)),
|
|
Error::RecursionLimitExceeded => panic!(),
|
|
};
|
|
|
|
let result: Result<Value, _> = from_reader(&bytes[..]);
|
|
let actual = match result.unwrap_err() {
|
|
Error::Io(..) => panic!(),
|
|
Error::Syntax(x) => ("syntax", Some(x), None),
|
|
Error::Semantic(x, y) => ("semantic", x, Some(y)),
|
|
Error::RecursionLimitExceeded => panic!(),
|
|
};
|
|
|
|
assert_eq!(correct, actual);
|
|
}
|
|
|
|
#[test]
|
|
fn test_long_utf8_deserialization() {
|
|
let s = (0..2000).map(|_| 'ボ').collect::<String>();
|
|
let mut v = Vec::new();
|
|
into_writer(&s, &mut v).unwrap();
|
|
let _: String = from_reader(&*v).unwrap();
|
|
}
|