zx::handle
. Note that since generated structures are views of an underlying buffer, a parent structure will only own child handles if it also owns their underlying buffer. For example, a FIDL struct owns all the handles stored inline, but a FIDL vector of structs containing handles will be represented as a vector view, which will not own the out-of-line handles.std::vector
, std::optional
, and std::string
.zx::handle
(libzx) to manage handle ownership.std::string
) to in-place buffers (e.g. as a fidl::StringView
).Category | Simple C | Low-level C++ | High-level C++ |
---|---|---|---|
audience | drivers | drivers and performance-critical applications | high-level services |
abstraction overhead | almost zero | almost zero | heap allocation, construction, destruction |
type safe types | enums, structs, unions | enums, structs, unions, handles, protocols | enums, structs, unions, handles, protocols |
storage | stack | stack, in-place buffer, or heap | heap |
lifecycle | manual free (POD) | manual free memory; own handles via RAII [1] | automatic free (RAII) |
receive behavior | copy | copy or decode in-place | decode then move to heap |
send behavior | copy | copy or encode in-place | move to buffer then encode |
calling protocol methods | free functions | free functions or proxy | call through proxies, register callbacks |
implementing protocol methods | manual dispatch or via ops table | manual dispatch or implement stub interface | implement stub object, invoke callbacks |
async client | no | no (planned) | yes |
async server | limited [2] | limited [2] | yes (unbounded) |
generated code footprint | small | moderate | large |
Notes:
fidl::DecodedMessage
object to manage all handles associated with a call.TODO