Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,19 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),

## [Unreleased]

### Added

- `serde::Serialize` is now implemented for generated view types when `generate_json` is
enabled, allowing zero-copy JSON serialization without `.to_owned_message()`.
`OwnedView<V>` also gains a blanket `Serialize` impl so `serde_json::to_string(&owned_view)`
works directly. **Known limitations:** (1) Messages whose view types nest a WKT view
(`TimestampView`, `DurationView`, `AnyView`, etc.) will fail to compile because WKT view
types do not yet implement `Serialize` — use `view.to_owned_message()` and serialize the
owned form as a workaround, or disable views (`generate_views(false)`) for those messages.
Hand-written WKT view `Serialize` impls are a planned follow-up. (2) Extension fields are
not included in view JSON output; serialize the owned form to include extensions.
([#83](https://github.com/anthropics/buffa/issues/83))

## [0.5.2] - 2026-05-07

### Fixed
Expand Down
19 changes: 15 additions & 4 deletions buffa-build/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,22 @@ impl Config {
self
}

/// Enable or disable serde Serialize/Deserialize derive generation
/// for generated message structs and enum types (default: false).
/// Enable or disable serde JSON generation (default: false).
///
/// When enabled, the downstream crate must depend on `serde` and enable
/// the `buffa/json` feature for the runtime helpers.
/// When enabled:
/// - Generated message structs get `Serialize`/`Deserialize` derives.
/// - Generated enum types get `Serialize`/`Deserialize` derives.
/// - Generated view types (when `generate_views` is also enabled) get a
/// manual `impl Serialize` for zero-copy JSON serialization.
///
/// The downstream crate must depend on `serde` and enable the `buffa/json`
/// feature for the runtime helpers.
///
/// **Limitation:** view types for messages that contain WKT fields
/// (`Timestamp`, `Duration`, `Any`, etc.) will fail to compile because WKT
/// view types do not yet implement `Serialize`. Call
/// `view.to_owned_message()` and serialize the owned form as a workaround,
/// or set `generate_views(false)` for affected files.
#[must_use]
pub fn generate_json(mut self, enabled: bool) -> Self {
self.codegen_config.generate_json = enabled;
Expand Down
Loading