通过驱动程序传输使用新的 C++ 绑定

如果协议具有 @transport("Driver") 属性,则该协议通过驱动程序传输(而不是 zircon 通道传输)运行:

library fuchsia.example;

@transport("Driver")
protocol Protocol {
    TwoWay(struct {
        request uint32;
    }) -> (struct {
        response uint32;
    });
};

驱动程序传输基于 Fuchsia 驱动程序运行时构建,与 Zircon 通道相比,该驱动程序具有不同的内存管理约束和线程模型。因此,FIDL 客户端和服务器类型与 Zircon 通道协议中的类型不同,以便提供定制的 API。

fidl:: 命名空间下的大多数客户端/服务器类型在 fdf:: 命名空间中都有对应项,它们提供相同的功能,但专用于驱动程序运行时。例如,虽然需要写入 fidl::Client 以通过 Zircon 通道传输声明异步客户端,但要使用上述示例协议,则需要写入 fdf::Client<fuchsia_example::Protocol>。生成的 FIDL 标头的格式为 #include <fidl/fuchsia.example/cpp/driver/fidl.h>

同样,当使用仅限传输类型的客户端和服务器 API 时,需要写入 fidl::WireClient 以通过 Zircon 通道传输声明异步客户端,而要使用上述示例协议,则需要写入 fdf::WireClient<fuchsia_example::Protocol>。一个可能会在 #include <fidl/fuchsia.example/cpp/driver/wire.h> 处包含导线子集头。

驱动程序传输上的 C++ 绑定正在迭代中。目前,这些测试可用作使用绑定的示例