If you don't read/write FIDL, or interact with generated FIDL bindings, you may stop reading now.
FIDL now supports using unions and tables as top-level method payloads:
This style is encouraged for new method definitions where appropriate, but already existing definitions will not be proactively converted to support this new syntax.
Today, a payload message that is a struct consisting of a single table and/or union is a fairly common pattern in FIDL living in fuchsia.git. Removing this unnecessary layer of indirection makes APIs like these easier to use, easier to evolve, and more directly expressive of their author's intent.
There are some differences in how the bindings will render table or union payloads. Unlike structs, which have all of their members "flattened" in most bindings, signatures for methods containing table or union payloads always have a single payload argument representing the entire table/union. Consider the following FIDL:
Which produces this HLCPP output:
And this Rust output:
The new one argument configuration for tables and unions makes method signatures easier to evolve: when a new field is added to the the request payload of UsingTable, none of the generated function signatures change, ensuring API compatibility. However, because UsingTable and UsingTableOld will produce different names in the resulting bindings, care must be taken to avoid API breakage when converting to the new syntax.
The API rubric will be updated to recommend using top-level unions and tables in lieu of their struct-wrapped alternatives, but there is no need to proactively update existing usages of that pattern.
I'm assuming that migrating from the table-in-struct way to inline-table is wire compatible but source breaking, is that correct? Or did the envelope struct affect the wire format in any way?
Pardon if this is a silly question,
I'm assuming that migrating from the table-in-struct way to inline-table is wire compatible but source breaking, is that correct? Or did the envelope struct affect the wire format in any way?
--
All posts must follow the Fuchsia Code of Conduct https://fuchsia.dev/fuchsia-src/CODE_OF_CONDUCT or may be removed.
---
You received this message because you are subscribed to the Google Groups "announce" group.
To unsubscribe from this group and stop receiving emails from it, send an email to announce+u...@fuchsia.dev.
To view this discussion on the web visit https://groups.google.com/a/fuchsia.dev/d/msgid/announce/CAPkkwny0VWP_ve6TyKG_UdO48AKa9RK3YiG5FVCBoe-Z3U-o5A%40mail.gmail.com.