V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
Kould
V2EX  ›  Rust

写了一个 KV 持久化数据库,想问一下有没有更好的序列化 api

  •  
  •   Kould · Aug 16, 2022 · 2456 views
    This topic created in 1360 days ago, the information mentioned may be changed or developed.

    https://github.com/KKould/KipDB/blob/master/src/core/mod.rs CommandPackage 的 form_read_to_vec 方法是获取文件中存放的序列化数据。以 json 为例子的话,序列化数据的排布: {"Set":{"key":"key1","value":"value1"}}{"Set":{"key":"key2","value":"value2"}}

    数据之间没有分隔符,serde_json 可以使用 StreamDeserializer 进行尝试读取,但使用 bincode 的话好像有个 deserializer_struct 方法,不过示例比较少,不知道怎么调用。V 友有类似的场景有比较成熟的处理方式吗

    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2984 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 15:17 · PVG 23:17 · LAX 08:17 · JFK 11:17
    ♥ Do have faith in what you're doing.