Switch back to postcard

This commit is contained in:
pjht 2024-06-18 16:39:37 -05:00
parent a74a802f76
commit 2504ff88fd
Signed by: pjht
GPG Key ID: 7B5F6AFBEC7EE78E
3 changed files with 93 additions and 38 deletions

121
Cargo.lock generated
View File

@ -2,6 +2,15 @@
# It is not intended for manual editing. # It is not intended for manual editing.
version = 3 version = 3
[[package]]
name = "atomic-polyfill"
version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8cf2bce30dfe09ef0bfaef228b9d414faaf7e563035494d7fe092dba54b300f4"
dependencies = [
"critical-section",
]
[[package]] [[package]]
name = "autocfg" name = "autocfg"
version = "1.3.0" version = "1.3.0"
@ -26,12 +35,24 @@ version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "cobs"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "67ba02a97a2bd10f4b59b25c7973101c79642302776489e030cd13cdab09ed15"
[[package]]
name = "critical-section"
version = "1.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7059fff8937831a9ae6f0fe4d658ffabf58f2ca96aa9dec1c889f936f705f216"
[[package]] [[package]]
name = "dev_driver_rpc" name = "dev_driver_rpc"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"parking_lot", "parking_lot",
"rmp-serde", "postcard",
"serde", "serde",
] ]
@ -51,19 +72,48 @@ name = "devfs_rpc"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"parking_lot", "parking_lot",
"rmp-serde", "postcard",
"serde", "serde",
] ]
[[package]]
name = "embedded-io"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ef1a6892d9eef45c8fa6b9e0086428a2cca8491aca8f787c534a3d6d0bcb3ced"
[[package]] [[package]]
name = "fs_rpc" name = "fs_rpc"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"parking_lot", "parking_lot",
"rmp-serde", "postcard",
"serde", "serde",
] ]
[[package]]
name = "hash32"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b0c35f58762feb77d74ebe43bdbc3210f09be9fe6742234d573bacc26ed92b67"
dependencies = [
"byteorder",
]
[[package]]
name = "heapless"
version = "0.7.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cdc6457c0eb62c71aac4bc17216026d8410337c4126773b9c5daba343f17964f"
dependencies = [
"atomic-polyfill",
"hash32",
"rustc_version",
"serde",
"spin",
"stable_deref_trait",
]
[[package]] [[package]]
name = "libc" name = "libc"
version = "0.2.155" version = "0.2.155"
@ -80,15 +130,6 @@ dependencies = [
"scopeguard", "scopeguard",
] ]
[[package]]
name = "num-traits"
version = "0.2.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841"
dependencies = [
"autocfg",
]
[[package]] [[package]]
name = "parking_lot" name = "parking_lot"
version = "0.12.3" version = "0.12.3"
@ -113,10 +154,16 @@ dependencies = [
] ]
[[package]] [[package]]
name = "paste" name = "postcard"
version = "1.0.15" version = "1.0.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" checksum = "a55c51ee6c0db07e68448e336cf8ea4131a620edefebf9893e759b2d793420f8"
dependencies = [
"cobs",
"embedded-io",
"heapless",
"serde",
]
[[package]] [[package]]
name = "proc-macro2" name = "proc-macro2"
@ -146,25 +193,12 @@ dependencies = [
] ]
[[package]] [[package]]
name = "rmp" name = "rustc_version"
version = "0.8.14" version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "228ed7c16fa39782c3b3468e974aec2795e9089153cd08ee2e9aefb3613334c4" checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366"
dependencies = [ dependencies = [
"byteorder", "semver",
"num-traits",
"paste",
]
[[package]]
name = "rmp-serde"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "52e599a477cf9840e92f2cde9a7189e67b42c57532749bf90aea6ec10facd4db"
dependencies = [
"byteorder",
"rmp",
"serde",
] ]
[[package]] [[package]]
@ -173,6 +207,12 @@ version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
[[package]]
name = "semver"
version = "1.0.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b"
[[package]] [[package]]
name = "serde" name = "serde"
version = "1.0.203" version = "1.0.203"
@ -199,6 +239,21 @@ version = "1.13.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67"
[[package]]
name = "spin"
version = "0.9.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67"
dependencies = [
"lock_api",
]
[[package]]
name = "stable_deref_trait"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3"
[[package]] [[package]]
name = "syn" name = "syn"
version = "2.0.66" version = "2.0.66"
@ -221,7 +276,7 @@ name = "vfs_rpc"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"parking_lot", "parking_lot",
"rmp-serde", "postcard",
"serde", "serde",
] ]

View File

@ -5,5 +5,5 @@ edition = "2021"
[dependencies] [dependencies]
parking_lot = "0.12.3" parking_lot = "0.12.3"
rmp-serde = "1.3.0" postcard = { version = "1.0.8", features = ["use-std"] }
serde = { version = "1.0.203", features = ["derive"] } serde = { version = "1.0.203", features = ["derive"] }

View File

@ -23,8 +23,8 @@ impl Client {
} }
pub fn register_dev(self, name: &str) -> Result<(), ()> { pub fn register_dev(self, name: &str) -> Result<(), ()> {
rmp_serde::from_slice( postcard::from_bytes(
&rpc::send_call(self.0, PROTO, 0, &rmp_serde::to_vec(name).unwrap()).get_return(), &rpc::send_call(self.0, PROTO, 0, &postcard::to_stdvec(name).unwrap()).get_return(),
) )
.unwrap() .unwrap()
} }
@ -44,8 +44,8 @@ fn callback(call: IncomingCall) {
let server_lock = SERVER.read(); let server_lock = SERVER.read();
let server = server_lock.as_ref().unwrap(); let server = server_lock.as_ref().unwrap();
if call.func == 0 { if call.func == 0 {
let kind = rmp_serde::from_slice(&call.args).unwrap(); let kind = postcard::from_bytes(&call.args).unwrap();
let ret = rmp_serde::to_vec(&server.register_dev(call.from, kind)).unwrap(); let ret = postcard::to_stdvec(&server.register_dev(call.from, kind)).unwrap();
call.send_return(&ret); call.send_return(&ret);
} }
} }