pub struct ServiceFsDir<'a, ServiceObjTy: ServiceObjTrait> { /* private fields */ }
Expand description

A directory within a ServiceFs.

Services and subdirectories can be added to it.

Implementations§

Adds a service connector to the directory.

let mut fs = ServiceFs::new_local();
fs
    .add_service_connector(|server_end: ServerEnd<EchoMarker>| {
        connect_channel_to_protocol::<EchoMarker>(
            server_end.into_channel(),
        )
    })
    .add_service_connector(|server_end: ServerEnd<CustomMarker>| {
        connect_channel_to_protocol::<CustomMarker>(
            server_end.into_channel(),
        )
    })
    .take_and_serve_directory_handle()?;

The FIDL service will be hosted at the name provided by the [Discoverable] annotation in the FIDL source.

Adds a service to the directory at the given path.

The path must be a single component containing no / characters.

Panics if any node has already been added at the given path.

Adds a FIDL service to the directory.

service is a closure that accepts a RequestStream. Each service being served must return an instance of the same type (ServiceObjTy::Output). This is necessary in order to multiplex multiple services over the same dispatcher code. The typical way to do this is to create an enum with variants for each service you want to serve.

enum MyServices {
    EchoServer(EchoRequestStream),
    CustomServer(CustomRequestStream),
    // ...
}

The constructor for a variant of the MyServices enum can be passed as the service parameter.

let mut fs = ServiceFs::new_local();
fs
    .add_fidl_service(MyServices::EchoServer)
    .add_fidl_service(MyServices::CustomServer)
    .take_and_serve_directory_handle()?;

ServiceFs can now be treated as a Stream of type MyServices.

const MAX_CONCURRENT: usize = 10_000;
fs.for_each_concurrent(MAX_CONCURRENT, |request: MyServices| {
    match request {
        MyServices::EchoServer(request) => handle_echo(request),
        MyServices::CustomServer(request) => handle_custom(request),
    }
}).await;

The FIDL service will be hosted at the name provided by the [Discoverable] annotation in the FIDL source.

Adds a FIDL service to the directory at the given path.

The path must be a single component containing no / characters.

See add_fidl_service for details.

Adds a FIDL service to the directory as the default instance.

The name of the default instance is DEFAULT_SERVICE_INSTANCE.

The FIDL service will be hosted at [SERVICE_NAME]/[default]/ where SERVICE_NAME is constructed from the FIDL library path and the name of the FIDL service.

Example

For the following FIDL definition,

library lib.foo;

service Bar {
  ...
}

The SERVICE_NAME of FIDL Service Bar would be lib.foo.Bar.

Adds a FIDL service to the directory as the default instance at the given path.

The path must be a single component containing no / characters. The name of the default instance is DEFAULT_SERVICE_INSTANCE.

The FIDL service will be hosted at [path]/default/.

Adds a named instance of a FIDL service to the directory.

The FIDL service will be hosted at [SERVICE_NAME]/[instance]/ where SERVICE_NAME is constructed from the FIDL library path and the name of the FIDL service.

The instance must be a single component containing no / characters.

Example

For the following FIDL definition,

library lib.foo;

service Bar {
  ...
}

The SERVICE_NAME of FIDL Service Bar would be lib.foo.Bar.

Adds a named instance of a FIDL service to the directory at the given path.

The FIDL service will be hosted at [path]/[instance]/.

The path and instance must be single components containing no / characters.

Adds a service that proxies requests to the current environment.

Adds a service that proxies requests to the given component.

Add a service to the ServicesServer that will launch a component upon request, proxying requests to the launched component.

Adds a VMO file to the directory at the given path.

The path must be a single component containing no / characters. The vmo should have content size set as required.

Panics if any node has already been added at the given path.

Returns a reference to the subdirectory at the given path, creating one if none exists.

The path must be a single component containing no / characters.

Panics if a service has already been added at the given path.

Adds a new remote directory served over the given DirectoryProxy.

The name must not contain any ‘/’ characters.

Adds a new remote served over the given NodeProxy. If the remote is a directory, add_remote should be used instead.

The name must not contain any ‘/’ characters.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The alignment of pointer.
The type for initializers.
Initializes a with the given initializer. Read more
Dereferences the given pointer. Read more
Mutably dereferences the given pointer. Read more
Drops the object pointed to by the given pointer. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more