小编Way*_*oke的帖子

如何为外部类型实现 serde 的序列化和反序列化特征?

我正在尝试实现Serialize外部Deserialize枚举,但我不知道如何实现。它有From<u64>所以我想做的只是让该对象序列化。

#[derive(Serialize, Deserialize)]
pub struct ImageBinds {
    binds: HashMap<KeybdKey, Vec<u8>>, // KeybdKey doesn't implement serialize
}

// won't compile with this:
// only traits defined in the current crate can be implemented for arbitrary types
// impl doesn't use only types from inside the current crate
// I understand the orphan rule and all that but I have no idea how else I'd implement it
// I've looked at serde remote stuff and I …
Run Code Online (Sandbox Code Playgroud)

rust serde

12
推荐指数
1
解决办法
5393
查看次数

标签 统计

rust ×1

serde ×1