Support existing types with custom conversions
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 30/100
調査の方向性
typify のソースにある import_types! の rustdoc と build.rs の例から始めます。with_conversion と with_replacement の文書化された動作を、それらの組み合わせも含めて比較し、生成されたフィールドがどのように serde 属性を受け取るかを追跡します。Done では、スキーマ固有の Rust 型を必要とせずに、カスタム文字列変換を使用する既存の std::time::Duration フィールドをサポートする必要があります。
索引モデルが issue の本文から書いたものです。
説明
I'm trying to use fields of type std::time::Duration and initialize them with strings like "500 ms". It doesn't appear to be possible right now.
I converted my code to build.rs so I can explore all documented functions. The import_types! documentation is unclear and insufficient. Actually, there is no example of build.rs in the rustdoc documentation, but I found an example in the typify sources.
Only with_replacement lets me replace a generated type with the existing one (std::time::Duration). The documentation for with_conversion appears to promise that behavior, but a new type is always generated. Combinations of with_replacement and other with_* don't seem to work.
Unfortunately, with_replacement doesn't let me specify custom serde for the field. Look e.g. for #[serde(with = "humantime_serde")] at https://docs.rs/humantime-serde/1.1.1/humantime_serde/ - it's specified on the field, not on the whole struct.
I tried some things with x-rust-type without any success. In any case, I don't see it as a clean approach. It should be possible for the schema to be Rust-agnostic and still support readable strings for duration.
Likewise, I don't want to use numbers for duration. It's too easy to confuse seconds with milliseconds.
Currently supported formats ("uuid", "date", "ip" etc) all support conversion from string. The problem with std::time::Duration is that it's standard (i.e. many std functions use it) but cannot be constructed from a string. So a different mechanism is needed.
- 主要言語
- Rust
- スター
- 907
- フォーク
- 115
- 平均マージ
- 20時間 24分
- マージ済み PR(30日)
- 15
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
oxidecomputer/typify のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
oxidecomputer/typify#1077 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 3/5 1〜2日 初心者へのやさしさ 55/100
oxidecomputer/typify#1075 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 50/100
oxidecomputer/typify#1060 ·
メンテナーはふだん 1 日以内に返信
-
難易度 5/5 1週間以上 初心者へのやさしさ 48/100
oxidecomputer/typify#1059 ·
メンテナーはふだん 1 日以内に返信
-
難易度 3/5 1〜2日 初心者へのやさしさ 65/100
oxidecomputer/typify#1022 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
oxidecomputer/typify の issue をすべて見る
似ている issue
-
agent:triaged bug bughunt pm:npm priority:p1
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
SocketDev/socket-patch#1127 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
-
documentation enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
adorsys/status-list-server#619 ·
メンテナーはふだん 2 日以内に返信
-
batch-backport only backports the first 30 matching PRs対応中かも @DvirDukhan が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 5 日以内に返信
-
Configuration-level resource: `Allocate` rejects the kubelet's re-offer of the same device for a later container of the same Pod ("Unable to claim slot")対応中かも @fang80913 が 38 日前に担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
project-akri/akri#854 ·