Skip to content

Commit 63d3c9a

Browse files
committed
replace bincode by wincode
1 parent d4b0ab5 commit 63d3c9a

File tree

3 files changed

+80
-61
lines changed

3 files changed

+80
-61
lines changed

Cargo.lock

Lines changed: 68 additions & 45 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# coreutils (uutils)
22
# * see the repository LICENSE, README, and CONTRIBUTING files for more information
33

4-
# spell-checker:ignore (libs) bigdecimal datetime serde bincode gethostid kqueue libselinux mangen memmap uuhelp startswith constness expl unnested logind cfgs interner
4+
# spell-checker:ignore (libs) bigdecimal datetime serde wincode gethostid kqueue libselinux mangen memmap uuhelp startswith constness expl unnested logind cfgs interner
55

66
[package]
77
name = "coreutils"
@@ -572,9 +572,8 @@ xattr.workspace = true
572572
# to deserialize an utmpx struct into a binary file
573573
[target.'cfg(all(target_family= "unix",not(target_os = "macos")))'.dev-dependencies]
574574
serde = { version = "1.0.202", features = ["derive"] }
575-
bincode = { version = "2.0.1", features = ["serde"] }
576-
serde-big-array = "0.5.1"
577-
575+
wincode = "0.2.5"
576+
wincode-derive = "0.2.3"
578577

579578
[build-dependencies]
580579
phf_codegen.workspace = true

tests/by-util/test_uptime.rs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// For the full copyright and license information, please view the LICENSE
44
// file that was distributed with this source code.
55
//
6-
// spell-checker:ignore bincode serde utmp runlevel testusr testx boottime
6+
// spell-checker:ignore wincode serde utmp runlevel testusr testx boottime
77
#![allow(clippy::cast_possible_wrap, clippy::unreadable_literal)]
88

99
use uutests::at_and_ucmd;
@@ -95,11 +95,10 @@ fn test_uptime_with_non_existent_file() {
9595
)]
9696
#[allow(clippy::too_many_lines, clippy::items_after_statements)]
9797
fn test_uptime_with_file_containing_valid_boot_time_utmpx_record() {
98-
use bincode::{config, serde::encode_to_vec};
99-
use serde::Serialize;
100-
use serde_big_array::BigArray;
10198
use std::fs::File;
10299
use std::{io::Write, path::PathBuf};
100+
use wincode::serialize;
101+
use wincode_derive::SchemaWrite;
103102

104103
// This test will pass for freebsd but we currently don't support changing the utmpx file for
105104
// freebsd.
@@ -133,21 +132,21 @@ fn test_uptime_with_file_containing_valid_boot_time_utmpx_record() {
133132
const RUN_LVL: i32 = 1;
134133
const USER_PROCESS: i32 = 7;
135134

136-
#[derive(Serialize)]
135+
#[derive(SchemaWrite)]
137136
#[repr(C)]
138137
pub struct TimeVal {
139138
pub tv_sec: i32,
140139
pub tv_usec: i32,
141140
}
142141

143-
#[derive(Serialize)]
142+
#[derive(SchemaWrite)]
144143
#[repr(C)]
145144
pub struct ExitStatus {
146145
e_termination: i16,
147146
e_exit: i16,
148147
}
149148

150-
#[derive(Serialize)]
149+
#[derive(SchemaWrite)]
151150
#[repr(C, align(4))]
152151
pub struct Utmp {
153152
pub ut_type: i32,
@@ -156,7 +155,6 @@ fn test_uptime_with_file_containing_valid_boot_time_utmpx_record() {
156155
pub ut_id: [i8; 4],
157156

158157
pub ut_user: [i8; 32],
159-
#[serde(with = "BigArray")]
160158
pub ut_host: [i8; 256],
161159
pub ut_exit: ExitStatus,
162160
pub ut_session: i32,
@@ -224,10 +222,9 @@ fn test_uptime_with_file_containing_valid_boot_time_utmpx_record() {
224222
glibc_reserved: [0; 20],
225223
};
226224

227-
let config = config::legacy();
228-
let mut buf = encode_to_vec(utmp, config).unwrap();
229-
buf.append(&mut encode_to_vec(utmp1, config).unwrap());
230-
buf.append(&mut encode_to_vec(utmp2, config).unwrap());
225+
let mut buf = serialize(&utmp).unwrap();
226+
buf.append(&mut serialize(&utmp1).unwrap());
227+
buf.append(&mut serialize(&utmp2).unwrap());
231228
let mut f = File::create(path).unwrap();
232229
f.write_all(&buf).unwrap();
233230
}

0 commit comments

Comments
 (0)