pub struct ServiceFsDir<'a, ServiceObjTy: ServiceObjTrait> { /* private fields */ }Expand description
A directory within a ServiceFs.
Services and subdirectories can be added to it.
Implementations§
Source§impl<ServiceObjTy: ServiceObjTrait> ServiceFsDir<'_, ServiceObjTy>
impl<ServiceObjTy: ServiceObjTrait> ServiceFsDir<'_, ServiceObjTy>
Sourcepub fn add_service_connector<F, P>(&mut self, service: F) -> &mut Selfwhere
F: FnMut(ServerEnd<P>) -> ServiceObjTy::Output,
P: DiscoverableProtocolMarker,
FidlServiceServerConnector<F, P, ServiceObjTy::Output>: Into<ServiceObjTy>,
pub fn add_service_connector<F, P>(&mut self, service: F) -> &mut Selfwhere
F: FnMut(ServerEnd<P>) -> ServiceObjTy::Output,
P: DiscoverableProtocolMarker,
FidlServiceServerConnector<F, P, ServiceObjTy::Output>: Into<ServiceObjTy>,
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.
§Panics
Panics if any node has already been added with the discoverable protocol name.
Sourcepub fn add_service_at(
&mut self,
name: impl TryInto<Name, Error: Debug>,
service: impl Into<ServiceObjTy>,
) -> &mut Self
pub fn add_service_at( &mut self, name: impl TryInto<Name, Error: Debug>, service: impl Into<ServiceObjTy>, ) -> &mut Self
Adds a service to the directory with the given name.
§Panics
Panics if name is not a valid fuchsia.io [Name], or if any node has already been
added with the given name.
Sourcepub fn add_fidl_service<F, RS>(&mut self, service: F) -> &mut Selfwhere
F: FnMut(RS) -> ServiceObjTy::Output,
RS: RequestStream,
RS::Protocol: DiscoverableProtocolMarker,
FidlService<F, RS, ServiceObjTy::Output>: Into<ServiceObjTy>,
pub fn add_fidl_service<F, RS>(&mut self, service: F) -> &mut Selfwhere
F: FnMut(RS) -> ServiceObjTy::Output,
RS: RequestStream,
RS::Protocol: DiscoverableProtocolMarker,
FidlService<F, RS, ServiceObjTy::Output>: Into<ServiceObjTy>,
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.
§Panics
Panics if any node has already been added with the discoverable protocol name.
Sourcepub fn add_fidl_service_at<F, RS>(
&mut self,
name: impl TryInto<Name, Error: Debug>,
service: F,
) -> &mut Selfwhere
F: FnMut(RS) -> ServiceObjTy::Output,
RS: RequestStream,
RS::Protocol: DiscoverableProtocolMarker,
FidlService<F, RS, ServiceObjTy::Output>: Into<ServiceObjTy>,
pub fn add_fidl_service_at<F, RS>(
&mut self,
name: impl TryInto<Name, Error: Debug>,
service: F,
) -> &mut Selfwhere
F: FnMut(RS) -> ServiceObjTy::Output,
RS: RequestStream,
RS::Protocol: DiscoverableProtocolMarker,
FidlService<F, RS, ServiceObjTy::Output>: Into<ServiceObjTy>,
Adds a FIDL service to the directory with the given name.
See add_fidl_service for details.
§Panics
Panics if name is not a valid fuchsia.io [Name], or if any node has already
been added with the given name.
Sourcepub fn add_fidl_service_instance<F, SR>(
&mut self,
instance: impl TryInto<Name, Error: Debug>,
service: F,
) -> &mut Selfwhere
F: Fn(SR) -> ServiceObjTy::Output + Clone,
SR: ServiceRequest,
FidlServiceMember<F, SR, ServiceObjTy::Output>: Into<ServiceObjTy>,
pub fn add_fidl_service_instance<F, SR>(
&mut self,
instance: impl TryInto<Name, Error: Debug>,
service: F,
) -> &mut Selfwhere
F: Fn(SR) -> ServiceObjTy::Output + Clone,
SR: ServiceRequest,
FidlServiceMember<F, SR, ServiceObjTy::Output>: Into<ServiceObjTy>,
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.
§Example
For the following FIDL definition,
library lib.foo;
service Bar {
...
}The SERVICE_NAME of FIDL Service Bar would be lib.foo.Bar.
§Panics
Panics if instance is not a valid fuchsia.io [Name], or if an entry has already
been added that conflicts with the service or instance directory structure.
Sourcepub fn add_fidl_service_instance_at<F, SR>(
&mut self,
name: impl TryInto<Name, Error: Debug>,
instance: impl TryInto<Name, Error: Debug>,
service: F,
) -> &mut Selfwhere
F: Fn(SR) -> ServiceObjTy::Output + Clone,
SR: ServiceRequest,
FidlServiceMember<F, SR, ServiceObjTy::Output>: Into<ServiceObjTy>,
pub fn add_fidl_service_instance_at<F, SR>(
&mut self,
name: impl TryInto<Name, Error: Debug>,
instance: impl TryInto<Name, Error: Debug>,
service: F,
) -> &mut Selfwhere
F: Fn(SR) -> ServiceObjTy::Output + Clone,
SR: ServiceRequest,
FidlServiceMember<F, SR, ServiceObjTy::Output>: Into<ServiceObjTy>,
Adds a named instance of a FIDL service to the directory with the given name.
The FIDL service will be hosted at [name]/[instance]/.
§Panics
Panics if name or instance is not a valid fuchsia.io [Name], or if an entry has
already been added that conflicts with the service or instance directory structure.
Sourcepub fn add_proxy_service<P: DiscoverableProtocolMarker, O>(
&mut self,
) -> &mut Selfwhere
ServiceObjTy: From<Proxy<P, O>> + ServiceObjTrait<Output = O>,
pub fn add_proxy_service<P: DiscoverableProtocolMarker, O>(
&mut self,
) -> &mut Selfwhere
ServiceObjTy: From<Proxy<P, O>> + ServiceObjTrait<Output = O>,
Adds a service that proxies requests to the current environment.
The FIDL service will be hosted at the name provided by the [Discoverable] annotation
in the FIDL source.
§Panics
Panics if any node has already been added with the discoverable protocol name.
Sourcepub fn add_proxy_service_to<P: DiscoverableProtocolMarker, O>(
&mut self,
directory_request: Arc<ClientEnd<DirectoryMarker>>,
) -> &mut Selfwhere
ServiceObjTy: From<ProxyTo<P, O>> + ServiceObjTrait<Output = O>,
pub fn add_proxy_service_to<P: DiscoverableProtocolMarker, O>(
&mut self,
directory_request: Arc<ClientEnd<DirectoryMarker>>,
) -> &mut Selfwhere
ServiceObjTy: From<ProxyTo<P, O>> + ServiceObjTrait<Output = O>,
Adds a service that proxies requests to the given component.
The FIDL service will be hosted at the name provided by the [Discoverable] annotation
in the FIDL source.
§Panics
Panics if any node has already been added with the discoverable protocol name.
Sourcepub fn add_vmo_file_at(
&mut self,
name: impl TryInto<Name, Error: Debug>,
vmo: Vmo,
) -> &mut Self
pub fn add_vmo_file_at( &mut self, name: impl TryInto<Name, Error: Debug>, vmo: Vmo, ) -> &mut Self
Adds a VMO file to the directory with the given name.
The vmo should have content size set as required.
§Panics
Panics if name is not a valid fuchsia.io [Name], or if any node has already
been added with the given name.
Sourcepub fn add_entry_at(
&mut self,
name: impl TryInto<Name, Error: Debug>,
entry: Arc<dyn DirectoryEntry>,
) -> &mut Self
pub fn add_entry_at( &mut self, name: impl TryInto<Name, Error: Debug>, entry: Arc<dyn DirectoryEntry>, ) -> &mut Self
Adds an entry to the directory with the given name.
§Panics
Panics if name is not a valid fuchsia.io [Name], or if any node has already
been added with the given name.
Sourcepub fn dir(
&mut self,
name: impl TryInto<Name, Error: Debug>,
) -> ServiceFsDir<'_, ServiceObjTy>
pub fn dir( &mut self, name: impl TryInto<Name, Error: Debug>, ) -> ServiceFsDir<'_, ServiceObjTy>
Returns a reference to the subdirectory with the given name, creating one if none exists.
§Panics
Panics if name is not a valid fuchsia.io [Name], or if an entry has already
been added with the given name and it is not a directory.
Sourcepub fn add_remote(
&mut self,
name: impl TryInto<Name, Error: Debug>,
proxy: DirectoryProxy,
) -> &mut Self
pub fn add_remote( &mut self, name: impl TryInto<Name, Error: Debug>, proxy: DirectoryProxy, ) -> &mut Self
Adds a new remote directory served over the given DirectoryProxy.
§Panics
Panics if name is not a valid fuchsia.io [Name], or if any node has already
been added with the given name.
Sourcepub fn add_fidl_next_protocol<P, H>(
&mut self,
create_handler: impl Fn(Server<P, Channel>) -> H + Send + Sync + Clone + 'static,
) -> &mut Self
pub fn add_fidl_next_protocol<P, H>( &mut self, create_handler: impl Fn(Server<P, Channel>) -> H + Send + Sync + Clone + 'static, ) -> &mut Self
Adds a FIDL protocol to the directory.
The FIDL protocol will be hosted at the name provided by the Discoverable annotation
in the FIDL source.
§Panics
Panics if any node has already been added with the discoverable protocol name.
Sourcepub fn add_fidl_next_service_instance<S, H>(
&mut self,
instance_name: impl TryInto<Name, Error: Debug>,
handler: H,
) -> &mut Self
pub fn add_fidl_next_service_instance<S, H>( &mut self, instance_name: impl TryInto<Name, Error: Debug>, handler: H, ) -> &mut Self
Adds a FIDL service to the directory.
The FIDL service will be hosted at the name provided by the Discoverable annotation in
the FIDL source under [instance_name].
§Panics
Panics if instance_name is not a valid fuchsia.io [Name], or if an entry has
already been added that conflicts with the service or instance directory structure.
Sourcepub fn add_fidl_next_service_instance_at<S, H>(
&mut self,
name: impl TryInto<Name, Error: Debug>,
instance_name: impl TryInto<Name, Error: Debug>,
handler: H,
) -> &mut Self
pub fn add_fidl_next_service_instance_at<S, H>( &mut self, name: impl TryInto<Name, Error: Debug>, instance_name: impl TryInto<Name, Error: Debug>, handler: H, ) -> &mut Self
Adds a FIDL service to the directory with a custom service name.
The FIDL service will be hosted at [name]/[instance_name]/.
§Panics
Panics if name or instance_name is not a valid fuchsia.io [Name], or if an entry
has already been added that conflicts with the service or instance directory structure.
Auto Trait Implementations§
impl<'a, ServiceObjTy> !RefUnwindSafe for ServiceFsDir<'a, ServiceObjTy>
impl<'a, ServiceObjTy> !Sync for ServiceFsDir<'a, ServiceObjTy>
impl<'a, ServiceObjTy> !UnwindSafe for ServiceFsDir<'a, ServiceObjTy>
impl<'a, ServiceObjTy> Freeze for ServiceFsDir<'a, ServiceObjTy>
impl<'a, ServiceObjTy> Send for ServiceFsDir<'a, ServiceObjTy>where
ServiceObjTy: Send,
impl<'a, ServiceObjTy> Unpin for ServiceFsDir<'a, ServiceObjTy>
impl<'a, ServiceObjTy> UnsafeUnpin for ServiceFsDir<'a, ServiceObjTy>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
Source§impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
§impl<T> InstanceFromServiceTransport<T> for T
impl<T> InstanceFromServiceTransport<T> for T
§fn from_service_transport(handle: T) -> T
fn from_service_transport(handle: T) -> T
T to [Self]Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more