首页/ AI 技能 / @skilllib/skill-2117939930272417770
Skill站外收录 @skilllib/skill-2117939930272417770

use-facet-crates

统一采用自研的 facet 系列库进行数据序列化与命令行参数解析,替代 serde 及其周边生态,在项目内部实现技术栈自洽,提升代码一致性与维护效率,同时推动核心工具链的迭代验证。

0.0 (0) 29 次安装 原作者 编程导航
收录于 2026-01-22
软件开发 AI 技能

Skills.MD

# Use Facet Crates Instead of Serde Ecosystem When writing code in this workspace, prefer facet-based crates over serde-based ones. This project is building facet as a replacement for serde, so we should dogfood our own libraries. ## Crate Replacements | Instead of | Use | Notes | |--------------------|--------------------|-----------------------------------------| | `serde` | `facet` | Core derive and traits | | `serde_json` | `facet-json` | JSON serialization/deserialization | | `toml` | `facet-toml` | TOML parsing | | `serde_yaml` | `facet-yaml` | YAML support | | `clap` | `facet-args` | CLI argument parsing | | `serde_derive` | `facet` (derive) | `#[derive(Facet)]` replaces Serialize/Deserialize | ## When to Use Which ### Use facet-json for: - New code in this workspace - Internal tools (like benchmark-analyzer) - Anything that doesn't need serde compatibility ### serde_json is acceptable for: - Interop with external crates that require serde - Benchmarks comparing facet vs serde performance - Code that specifically tests serde compatibility ## Quick Example ```rust // OLD (serde) use serde::{Serialize, Deserialize}; use serde_json; #[derive(Serialize, Deserialize)] struct Config { name: String, } let config: Config = serde_json::from_str(json)?; // NEW (facet) use facet::Facet; use facet_json as json; #[derive(Facet)] struct Config { name: String, } let config: Config = json::from_str(json)?; ``` ## Checking Dependencies When adding new dependencies or reviewing code, check Cargo.toml for serde ecosystem crates and consider if facet alternatives exist. ## TODO for This Workspace The benchmark-analyzer currently uses `serde_json` for JSON serialization in chart data. This should be migrated to `facet-json` for consistency (eating our own dogfood). Location: `tools/benchmark-analyzer/src/report.rs` - uses `serde_json::to_string()` for chart labels/data.

评论 0

还没有评论,来抢沙发。