Capabilities can be created, routed, and used in a component manifest to control which parts of Fuchsia have ability to connect to and access which resources.
Component manifests declare how capabilities are routed between components. The language of capability routing consists of the following three keywords:
use
: When a component uses
a capability, the capability is installed in the component's namespace. A component may use
any capability that has been offered
or exposed
to it.offer
: A component may offer
a capability to a target, which is either a child or collection. When a capability is offered to a child, the child instance may use
the capability or offer
it to one of its own targets. Likewise, when a capability is offered to a collection, any instance in the collection may use
the capability or offer
it.expose
: When a component exposes
a capability to its parent, the parent may offer
the capability to one of its other children. A component may expose
any capability that it provides, or that one of its children exposes.When you use these keywords together, they express how a capability is routed from a component instance‘s outgoing directory to another component instance’s namespace:
use
describes the capabilities that populate a component instance's namespace.expose
and offer
describe how capabilities are passed between component instances. Aside from their directionality, there is another significant difference between offer
and expose
. A component may freely use
a capability that was offered
to it, however, in order to prevent dependency cycles between parents and children there are restrictions on using
a capability that is exposed
to a component by its child. If the parent offers no capabilities to the child which the parent itself provides, then it can use
from its child. If the parent does offer capabilities that it provides, then the use
from the child must be marked as weak
.directory
, event
, protocol
, service
and storage
capabilities are routed to components that use
them. resolver
and runner
capabilities are routed to environments that include them.
For more information on what happens when connecting to a capability, see Life of a protocol open.