This is an automated email from the ASF dual-hosted git repository. chaokunyang pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/fory-site.git
commit 98cf99c0540ae854be53c4317cf364e678acaed4 Author: chaokunyang <[email protected]> AuthorDate: Fri May 15 14:58:11 2026 +0000 🔄 synced local 'docs/compiler/' with remote 'docs/compiler/' --- docs/compiler/compiler-guide.md | 9 +++++- docs/compiler/schema-idl.md | 70 ++++++++++++++++++++++++++++++----------- 2 files changed, 60 insertions(+), 19 deletions(-) diff --git a/docs/compiler/compiler-guide.md b/docs/compiler/compiler-guide.md index a1c35e0268..8cefb9abf5 100644 --- a/docs/compiler/compiler-guide.md +++ b/docs/compiler/compiler-guide.md @@ -73,7 +73,14 @@ Compile options: | `--emit-fdl` | Emit translated FDL (for non-FDL inputs) | `false` | | `--emit-fdl-path` | Write translated FDL to this path (file or directory) | (stdout) | -For both `go_nested_type_style` and `swift_namespace_style`, schema-level file options are supported (`option ... = ...;`) and the CLI flag overrides the schema option when both are present. +Schema-level file options are supported for language-specific generation choices. +For `go_nested_type_style` and `swift_namespace_style`, the CLI flag overrides +the schema option when both are present. Rust temporal codegen has no CLI flag: +set `option rust_use_chrono_temporal_types = true;` in the schema to generate +`chrono::NaiveDate`, `chrono::NaiveDateTime`, and `chrono::Duration` instead of +the default `fory::Date`, `fory::Timestamp`, and `fory::Duration`. Crates that +compile generated chrono-based Rust code must depend on `chrono` and enable +Fory's `chrono` feature. Scan options (with `--scan-generated`): diff --git a/docs/compiler/schema-idl.md b/docs/compiler/schema-idl.md index b30ce90831..784bb9610f 100644 --- a/docs/compiler/schema-idl.md +++ b/docs/compiler/schema-idl.md @@ -217,6 +217,29 @@ message Payment { The CLI flag `--swift_namespace_style` overrides this schema option when both are set. +### Rust Chrono Temporal Types Option + +Rust generated code uses Fory's lightweight temporal carrier types by default: +`fory::Date`, `fory::Timestamp`, and `fory::Duration`. Set +`rust_use_chrono_temporal_types` when the generated Rust API should expose +chrono temporal types instead: + +```protobuf +package payment; +option rust_use_chrono_temporal_types = true; + +message Event { + date business_day = 1; + timestamp created_at = 2; + duration timeout = 3; +} +``` + +With this option, Rust code maps `date` to `chrono::NaiveDate`, `timestamp` to +`chrono::NaiveDateTime`, and `duration` to `chrono::Duration`. The Rust crate +that compiles the generated code must depend on `chrono` and enable Fory's +`chrono` feature. + ### Java Outer Classname Option Generate all types as inner classes of a single outer wrapper class: @@ -1150,27 +1173,38 @@ Underscore spellings for integer encoding are not FDL type names. ##### Date -| Language | Type | Notes | -| ---------- | --------------------------- | ----------------------- | -| Java | `java.time.LocalDate` | | -| Python | `datetime.date` | | -| Go | `time.Time` | Time portion ignored | -| Rust | `chrono::NaiveDate` | Requires `chrono` crate | -| C++ | `fory::serialization::Date` | | -| JavaScript | `Date` | | -| Dart | `LocalDate` | Fory package type | +| Language | Type | Notes | +| ---------- | --------------------------- | --------------------------------------------------------------------------- | +| Java | `java.time.LocalDate` | | +| Python | `datetime.date` | | +| Go | `time.Time` | Time portion ignored | +| Rust | `fory::Date` | Set `rust_use_chrono_temporal_types = true` to generate `chrono::NaiveDate` | +| C++ | `fory::serialization::Date` | | +| JavaScript | `Date` | | +| Dart | `LocalDate` | Fory package type | ##### Timestamp -| Language | Type | Notes | -| ---------- | -------------------------------- | ----------------------- | -| Java | `java.time.Instant` | UTC-based | -| Python | `datetime.datetime` | | -| Go | `time.Time` | | -| Rust | `chrono::NaiveDateTime` | Requires `chrono` crate | -| C++ | `fory::serialization::Timestamp` | | -| JavaScript | `Date` | | -| Dart | `Timestamp` | Fory package type | +| Language | Type | Notes | +| ---------- | -------------------------------- | ------------------------------------------------------------------------------- | +| Java | `java.time.Instant` | UTC-based | +| Python | `datetime.datetime` | | +| Go | `time.Time` | | +| Rust | `fory::Timestamp` | Set `rust_use_chrono_temporal_types = true` to generate `chrono::NaiveDateTime` | +| C++ | `fory::serialization::Timestamp` | | +| JavaScript | `Date` | | +| Dart | `Timestamp` | Fory package type | + +##### Duration + +| Language | Type | Notes | +| -------- | ------------------------------- | -------------------------------------------------------------------------- | +| Java | `java.time.Duration` | | +| Python | `datetime.timedelta` | | +| Go | `time.Duration` | | +| Rust | `fory::Duration` | Set `rust_use_chrono_temporal_types = true` to generate `chrono::Duration` | +| C++ | `fory::serialization::Duration` | | +| Dart | `Duration` | | #### Any --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
