diff --git a/Cargo.lock b/Cargo.lock index 78fd65353..0ee582fe7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -165,26 +165,6 @@ dependencies = [ "compare", ] -[[package]] -name = "bincode" -version = "2.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36eaf5d7b090263e8150820482d5d93cd964a81e4019913c972f4edcc6edb740" -dependencies = [ - "bincode_derive", - "serde", - "unty", -] - -[[package]] -name = "bincode_derive" -version = "2.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf95709a440f45e986983918d0e8a1f30a9b1df04918fc828670606804ac3c09" -dependencies = [ - "virtue", -] - [[package]] name = "bindgen" version = "0.72.1" @@ -536,7 +516,6 @@ checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" name = "coreutils" version = "0.5.0" dependencies = [ - "bincode", "clap", "clap_complete", "clap_mangen", @@ -558,7 +537,6 @@ dependencies = [ "rstest", "selinux", "serde", - "serde-big-array", "sha1", "tempfile", "textwrap", @@ -669,6 +647,8 @@ dependencies = [ "uucore", "uutests", "walkdir", + "wincode", + "wincode-derive", "xattr", "zip", ] @@ -813,6 +793,41 @@ dependencies = [ "windows-sys 0.59.0", ] +[[package]] +name = "darling" +version = "0.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9cdf337090841a411e2a7f3deb9187445851f91b309c0c0a29e05f74a00a48c0" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1247195ecd7e3c85f83c8d2a366e4210d588e802133e1e355180a9870b517ea4" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn", +] + +[[package]] +name = "darling_macro" +version = "0.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d38308df82d1080de0afee5d069fa14b0326a88c14f15c5ccda35b4a6c414c81" +dependencies = [ + "darling_core", + "quote", + "syn", +] + [[package]] name = "data-encoding" version = "2.9.0" @@ -1471,6 +1486,12 @@ dependencies = [ "zerovec", ] +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + [[package]] name = "indexmap" version = "2.9.0" @@ -2518,15 +2539,6 @@ dependencies = [ "serde_derive", ] -[[package]] -name = "serde-big-array" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11fc7cc2c76d73e0f27ee52abbd64eec84d46f370c88371120433196934e4b7f" -dependencies = [ - "serde", -] - [[package]] name = "serde_core" version = "1.0.228" @@ -2729,9 +2741,9 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "syn" -version = "2.0.103" +version = "2.0.114" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4307e30089d6fd6aff212f2da3a1f9e32f3223b1f010fb09b7c95f90f3ca1e8" +checksum = "d4d107df263a3013ef9b1879b0df87d706ff80f65a86ea879bd9c31f9b307c2a" dependencies = [ "proc-macro2", "quote", @@ -2974,12 +2986,6 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "81e544489bf3d8ef66c953931f56617f423cd4b5494be343d9b9d3dda037b9a3" -[[package]] -name = "unty" -version = "0.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d49784317cd0d1ee7ec5c716dd598ec5b4483ea832a2dced265471cc0f690ae" - [[package]] name = "utf16_iter" version = "1.0.5" @@ -4299,12 +4305,6 @@ version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" -[[package]] -name = "virtue" -version = "0.0.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "051eb1abcf10076295e815102942cc58f9d5e3b4560e46e53c21e8ff6f3af7b1" - [[package]] name = "vsimd" version = "0.8.0" @@ -4444,6 +4444,29 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "wincode" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5cec722a3274e47d1524cbe2cea762f2c19d615bd9d73ada21db9066349d57e" +dependencies = [ + "proc-macro2", + "quote", + "thiserror 2.0.17", +] + +[[package]] +name = "wincode-derive" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8961eb04054a1b2e026b5628e24da7e001350249a787e1a85aa961f33dc5f286" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "windows-core" version = "0.62.2" diff --git a/Cargo.toml b/Cargo.toml index c4109656b..77738518f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ # coreutils (uutils) # * see the repository LICENSE, README, and CONTRIBUTING files for more information -# spell-checker:ignore (libs) bigdecimal datetime serde bincode gethostid kqueue libselinux mangen memmap uuhelp startswith constness expl unnested logind cfgs interner +# spell-checker:ignore (libs) bigdecimal datetime serde wincode gethostid kqueue libselinux mangen memmap uuhelp startswith constness expl unnested logind cfgs interner [package] name = "coreutils" @@ -572,9 +572,8 @@ xattr.workspace = true # to deserialize an utmpx struct into a binary file [target.'cfg(all(target_family= "unix",not(target_os = "macos")))'.dev-dependencies] serde = { version = "1.0.202", features = ["derive"] } -bincode = { version = "2.0.1", features = ["serde"] } -serde-big-array = "0.5.1" - +wincode = "0.2.5" +wincode-derive = "0.2.3" [build-dependencies] phf_codegen.workspace = true diff --git a/tests/by-util/test_uptime.rs b/tests/by-util/test_uptime.rs index e47599912..5c1d5d15f 100644 --- a/tests/by-util/test_uptime.rs +++ b/tests/by-util/test_uptime.rs @@ -3,7 +3,7 @@ // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. // -// spell-checker:ignore bincode serde utmp runlevel testusr testx boottime +// spell-checker:ignore wincode serde utmp runlevel testusr testx boottime #![allow(clippy::cast_possible_wrap, clippy::unreadable_literal)] use uutests::at_and_ucmd; @@ -95,11 +95,10 @@ fn test_uptime_with_non_existent_file() { )] #[allow(clippy::too_many_lines, clippy::items_after_statements)] fn test_uptime_with_file_containing_valid_boot_time_utmpx_record() { - use bincode::{config, serde::encode_to_vec}; - use serde::Serialize; - use serde_big_array::BigArray; use std::fs::File; use std::{io::Write, path::PathBuf}; + use wincode::serialize; + use wincode_derive::SchemaWrite; // This test will pass for freebsd but we currently don't support changing the utmpx file for // freebsd. @@ -133,21 +132,21 @@ fn test_uptime_with_file_containing_valid_boot_time_utmpx_record() { const RUN_LVL: i32 = 1; const USER_PROCESS: i32 = 7; - #[derive(Serialize)] + #[derive(SchemaWrite)] #[repr(C)] pub struct TimeVal { pub tv_sec: i32, pub tv_usec: i32, } - #[derive(Serialize)] + #[derive(SchemaWrite)] #[repr(C)] pub struct ExitStatus { e_termination: i16, e_exit: i16, } - #[derive(Serialize)] + #[derive(SchemaWrite)] #[repr(C, align(4))] pub struct Utmp { pub ut_type: i32, @@ -156,7 +155,6 @@ fn test_uptime_with_file_containing_valid_boot_time_utmpx_record() { pub ut_id: [i8; 4], pub ut_user: [i8; 32], - #[serde(with = "BigArray")] pub ut_host: [i8; 256], pub ut_exit: ExitStatus, pub ut_session: i32, @@ -224,10 +222,9 @@ fn test_uptime_with_file_containing_valid_boot_time_utmpx_record() { glibc_reserved: [0; 20], }; - let config = config::legacy(); - let mut buf = encode_to_vec(utmp, config).unwrap(); - buf.append(&mut encode_to_vec(utmp1, config).unwrap()); - buf.append(&mut encode_to_vec(utmp2, config).unwrap()); + let mut buf = serialize(&utmp).unwrap(); + buf.append(&mut serialize(&utmp1).unwrap()); + buf.append(&mut serialize(&utmp2).unwrap()); let mut f = File::create(path).unwrap(); f.write_all(&buf).unwrap(); }