【视频】OSO 如何为 Rust 构建运行时反射系统
NoProto: 比 BSON 快 10 倍
和 BSON 一样,是一种二进制 JSON 数据格式。具有零依赖、no_std 支持、WASM 支持等特性。
性能比较:
使用实例:
use no_proto::error::NP_Error;
use no_proto::NP_Factory;
use no_proto::collection::table::NP_Table;
// JSON is used to describe schema for the factory
// Each factory represents a single schema
// One factory can be used to serialize/deserialize any number of buffers
let user_factory = NP_Factory::new(r#"{
"type": "table",
"columns": [
["name", {"type": "string"}],
["age", {"type": "u16", "default": 0}],
["tags", {"type": "list", "of": {
"type": "string"
}}]
]
}"#)?;
// create a new empty buffer
let mut user_buffer = user_factory.empty_buffer(None); // optional capacity, optional address size (u16 by default)
// set an internal value of the buffer, set the "name" column
user_buffer.set(&["name"], "Billy Joel")?;
// assign nested internal values, sets the first tag element
user_buffer.set(&["tags", "0"], "first tag")?;
// get an internal value of the buffer from the "name" column
let name = user_buffer.get::<&str>(&["name"])?;
assert_eq!(name, Some("Billy Joel"));
// close buffer and get internal bytes
let user_bytes: Vec<u8> = user_buffer.close();
// open the buffer again
let user_buffer = user_factory.open_buffer(user_bytes);
// get nested internal value, first tag from the tag list
let tag = user_buffer.get::<&str>(&["tags", "0"])?;
assert_eq!(tag, Some("first tag"));
// get nested internal value, the age field
let age = user_buffer.get::<u16>(&["age"])?;
// returns default value from schema
assert_eq!(age, Some(0u16));
// close again
let user_bytes: Vec<u8> = user_buffer.close();
// we can now save user_bytes to disk,
// send it over the network, or whatever else is needed with the data
Mundane: google 出品 Rust 密码学库
基于 BoringSSL,难以被滥用,符合开发者使用习惯并且性能优异。
https://github.com/google/mundane
FFI-Safe 生态:瘦 Trait 对象(Thin Trait Objects)
https://adventures.michaelfbryan.com/posts/ffi-safe-polymorphism-in-rust/
隐私聊天 APP Signal 使用 Rust 完成群组通话功能
详细代码:
https://github.com/signalapp/ringrtc/blob/master/src/rust/src/core/group_call.rs
From 日报小组 @挺肥
社区学习交流平台订阅:
1
共 0 条评论, 1 页
评论区
写评论还没有评论