Kould
V2EX  ›  Rust

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

  •  
  •   Kould · Aug 16, 2022 · 2553 views
    This topic created in 1392 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   ·   3025 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 36ms · UTC 14:23 · PVG 22:23 · LAX 07:23 · JFK 10:23
    ♥ Do have faith in what you're doing.