This page contains a list of the examples intended to demonstrate Fuchsia
driver concepts.

## Basic examples

These examples demonstrate common [driver concepts](https://fuchsia.dev/docs/concepts/drivers/README):

- **Skeleton driver** - The [skeleton driver example](https://cs.opensource.google/fuchsia/fuchsia/+/main:/examples/drivers/skeleton/) is
  a minimal driver.

- **Template driver** - The [template driver example](https://cs.opensource.google/fuchsia/fuchsia/+/main:/examples/drivers/template/) is a
  minimal driver built with SDK rules (which can be used in both the Fuchsia
  source checkout and Fuchsia SDK environments).

- **Simple driver** - The [simple driver example](https://cs.opensource.google/fuchsia/fuchsia/+/main:/examples/drivers/simple/dfv2/) demonstrates
  how to write a driver with the following common patterns:

  - Adding logs
  - Adding a child node
  - Implementing stop functions
- **Metadata** - The [metadata example](https://cs.opensource.google/fuchsia/fuchsia/+/main:/examples/drivers/metadata/) demonstrates how
  to define metadata types and pass metadata from a driver to its children.

## Transport examples

These examples demonstrate communication between drivers:

- **Zircon transport** - The [Zircon transport example](https://cs.opensource.google/fuchsia/fuchsia/+/main:/examples/drivers/transport/zircon/v2/)
  demonstrates a parent driver serving a FIDL protocol over Zircon transport and
  a child driver that connects and queries data from it.

- **Driver transport** - The [driver transport example](https://cs.opensource.google/fuchsia/fuchsia/+/main:/examples/drivers/transport/driver/v2/)
  demonstrates a parent driver serving a FIDL protocol over driver transport and
  a child driver that connects and queries data from it.

## Bind examples

These examples demonstrate how to write and use bind libraries for drivers:

- **Bind library** - The [bind library example](https://cs.opensource.google/fuchsia/fuchsia/+/main:/examples/drivers/bind/bindlib/) demonstrates how to
  write a bind library.

- **Bind library codegen** - The [bind library codegen example](https://cs.opensource.google/fuchsia/fuchsia/+/main:/examples/drivers/bind/bindlib_codegen/)
  demonstrates how to use the C++ and Rust constants generated from a bind
  library.

## Test examples

These examples demonstrate writing unit and integration tests for drivers.

### Unit tests

Unit test examples:

- [**Simple driver**](https://cs.opensource.google/fuchsia/fuchsia/+/main:/examples/drivers/simple/dfv2/tests/) - Barebones unit test for the simple driver example
- [**Zircon transport**](https://cs.opensource.google/fuchsia/fuchsia/+/main:/examples/drivers/transport/zircon/v2/tests/) - Unit test that verifies that the child driver can query from a fake FIDL zircon server
- [**Driver transport**](https://cs.opensource.google/fuchsia/fuchsia/+/main:/examples/drivers/transport/driver/v2/tests/) - Unit test that verifies that the child driver can query from a fake FIDL driver server

### Integration tests

The [Driver Test Realm examples](https://cs.opensource.google/fuchsia/fuchsia/+/main:/examples/drivers/driver_test_realm/) demonstrate how to write
hermetic and non-hermetic integration tests for a driver.
[](https://issues.fuchsia.dev/issues/new?component=1439230&template=1881640&description=Issue+on:+https://fuchsia.dev/docs/development/drivers/developer_guide/driver-examples.md "Report a bug or suggest improvements on this page") [](https://cs.opensource.google/fuchsia/fuchsia/+/main:docs/development/drivers/developer_guide/driver-examples.md "View the source code of this page") [](https://ci.android.com/edit?repo=fuchsia/fuchsia/main&file=docs/development/drivers/developer_guide/driver-examples.md&cloneRepo=fuchsia/fuchsia:refs/heads/main&fullPath=fuchsia/docs/development/drivers/developer_guide/driver-examples.md "Edit the source code of this page")