Restore manganis optimizations (#3195)
* Create a crate for constant serialization of config structs for manganis * use SerializeConst for the image asset builder * switch to a declarative macro for assets * add serializable options for each asset type * implement the new manganis macro * optimize assets in the CLI * Fix assets with dioxus formattable * reduce fuzzing test limits * use the new syntax in examples * fix avif support * Fix manganis doc tests * cache asset optimization * Split out asset and bundled asset * make hash pointer width independent * Fix manganis macro docs * add constvec::is_empty method to fix clippy lint * remove nasm feature * simplify test_rsplit_once test so typos passes * revert example change from clippy fix * always accept unix paths * fix windows path seperator * fix folder asset hash * Optimize assets in a blocking task * Fix asset options docs * Document Asset and BundledAsset * simplify the linker macro a bit * add more docs to AssetParser expansion * add image format helpers * Split by both unix and windows path separators and take the smallest one
This commit is contained in:
1 parent
31d72db82d
commit
f9617c8d33
64 files changed
+6233
-704
No files matched your search
@@ -0,0 +1,71 @@
|
||||
use const_serialize::{deserialize_const, serialize_const, ConstVec};
|
||||
|
||||
#[test]
|
||||
fn test_serialize_const_layout_primitive() {
|
||||
let mut buf = ConstVec::new();
|
||||
buf = serialize_const(&1234u32, buf);
|
||||
if cfg!(feature = "test-big-endian") {
|
||||
assert_eq!(buf.as_ref(), 1234u32.to_be_bytes());
|
||||
} else {
|
||||
assert_eq!(buf.as_ref(), 1234u32.to_le_bytes());
|
||||
}
|
||||
let buf = buf.read();
|
||||
assert_eq!(deserialize_const!(u32, buf).unwrap().1, 1234u32);
|
||||
|
||||
let mut buf = ConstVec::new();
|
||||
buf = serialize_const(&1234u64, buf);
|
||||
if cfg!(feature = "test-big-endian") {
|
||||
assert_eq!(buf.as_ref(), 1234u64.to_be_bytes());
|
||||
} else {
|
||||
assert_eq!(buf.as_ref(), 1234u64.to_le_bytes());
|
||||
}
|
||||
let buf = buf.read();
|
||||
assert_eq!(deserialize_const!(u64, buf).unwrap().1, 1234u64);
|
||||
|
||||
let mut buf = ConstVec::new();
|
||||
buf = serialize_const(&1234i32, buf);
|
||||
if cfg!(feature = "test-big-endian") {
|
||||
assert_eq!(buf.as_ref(), 1234i32.to_be_bytes());
|
||||
} else {
|
||||
assert_eq!(buf.as_ref(), 1234i32.to_le_bytes());
|
||||
}
|
||||
let buf = buf.read();
|
||||
assert_eq!(deserialize_const!(i32, buf).unwrap().1, 1234i32);
|
||||
|
||||
let mut buf = ConstVec::new();
|
||||
buf = serialize_const(&1234i64, buf);
|
||||
if cfg!(feature = "test-big-endian") {
|
||||
assert_eq!(buf.as_ref(), 1234i64.to_be_bytes());
|
||||
} else {
|
||||
assert_eq!(buf.as_ref(), 1234i64.to_le_bytes());
|
||||
}
|
||||
let buf = buf.read();
|
||||
assert_eq!(deserialize_const!(i64, buf).unwrap().1, 1234i64);
|
||||
|
||||
let mut buf = ConstVec::new();
|
||||
buf = serialize_const(&true, buf);
|
||||
assert_eq!(buf.as_ref(), [1u8]);
|
||||
let buf = buf.read();
|
||||
assert!(deserialize_const!(bool, buf).unwrap().1);
|
||||
|
||||
let mut buf = ConstVec::new();
|
||||
buf = serialize_const(&0.631f32, buf);
|
||||
if cfg!(feature = "test-big-endian") {
|
||||
assert_eq!(buf.as_ref(), 0.631f32.to_be_bytes());
|
||||
} else {
|
||||
assert_eq!(buf.as_ref(), 0.631f32.to_le_bytes());
|
||||
}
|
||||
let buf = buf.read();
|
||||
assert_eq!(deserialize_const!(f32, buf).unwrap().1, 0.631);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
fn test_serialize_primitive_too_little_data() {
|
||||
let mut buf = ConstVec::new();
|
||||
buf = buf.push(1);
|
||||
buf = buf.push(1);
|
||||
buf = buf.push(1);
|
||||
let buf = buf.read();
|
||||
assert_eq!(deserialize_const!(u64, buf), None);
|
||||
}
|
||||
Reference in new issue
Block a user