pub struct ScopedInstanceFactory { /* private fields */ }
Expand description
Manages the creation of new components within a collection.
Implementations§
Source§impl ScopedInstanceFactory
impl ScopedInstanceFactory
Sourcepub fn new(collection_name: impl Into<String>) -> Self
pub fn new(collection_name: impl Into<String>) -> Self
Creates a new factory that creates components in the specified collection.
Sourcepub fn with_realm_proxy(self, realm_proxy: RealmProxy) -> Self
pub fn with_realm_proxy(self, realm_proxy: RealmProxy) -> Self
Use realm_proxy
instead of the fuchsia.component.Realm protocol in this component’s
incoming namespace. This can be used to start component’s in a collection belonging
to another component.
Sourcepub async fn new_instance(
&self,
url: impl Into<String>,
) -> Result<ScopedInstance, Error>
pub async fn new_instance( &self, url: impl Into<String>, ) -> Result<ScopedInstance, Error>
Creates and binds to a new component just like new_named_instance
, but uses an
autogenerated name for the instance.
Sourcepub async fn new_named_instance(
&self,
child_name: impl Into<String>,
url: impl Into<String>,
) -> Result<ScopedInstance, Error>
pub async fn new_named_instance( &self, child_name: impl Into<String>, url: impl Into<String>, ) -> Result<ScopedInstance, Error>
Creates and binds to a new component named child_name
with url
.
A ScopedInstance is returned on success, representing the component’s lifetime and
providing access to the component’s exposed capabilities.
When the ScopedInstance is dropped, the component will be asynchronously stopped and destroyed.
This is useful for tests that wish to create components that should be torn down at the end of the test, or to explicitly control the lifecycle of a component.