fn serve_view_protocols(
    kernel: Weak<Kernel>,
    mut executor: fasync::LocalExecutor,
    display_socket: SocketHandle,
    outgoing_dir_channel: zx::Channel,
    wayland_server_channel: zx::Channel,
    wayland_bridge: zx::Channel,
    view_producer: fwayland::ViewProducerProxy,
    wayland_dispatcher: fvirt::WaylandDispatcherProxy,
) -> Result<(), Error> {
    // Inform the dispatcher of the connected client. This should be done on a per client basis,
    // but for now this assumes that only one wayland client is running in the same starnix
    // instance.
    wayland_dispatcher.on_new_connection(wayland_server_channel)?;

    // Add `ViewProvider` to the exposed services of the component, and then serve the
    // outgoing directory.
    let mut outgoing_dir = ServiceFs::new_local();
    outgoing_dir.dir("svc").add_fidl_service(ExposedServices::ViewProvider);
    outgoing_dir.serve_connection(outgoing_dir_channel)?;

    // Handle communication between the wayland client and wayland bridge.
    let _display_server_thread = std::thread::spawn(move || -> Result<(), Errno> {
        let _executor = fasync::LocalExecutor::new().map_err(|_| errno!(ENOMEM));
        serve_display_socket(kernel, display_socket, wayland_bridge)?;
        Ok(())
    });

    let mut view_producer_events = view_producer.take_event_stream();
    let view_provider = match executor.run_singlethreaded(view_producer_events.next()) {
        Some(Ok(fwayland::ViewProducerEvent::OnNewView { view_provider, id: _id })) => {
            view_provider
                .into_proxy()
                .map_err(|_| anyhow!("Error converting view provider into proxy."))
        }
        _ => Err(anyhow!("Error getting view producer's OnNewView.")),
    }?;

    executor.run_singlethreaded(serve_view_provider(view_provider, outgoing_dir));

    Ok(())
}
/// Serves the view-related protocols on behalf of the component that is running.
///
/// This function also spawns a thread to proxy data between the wayland bridge and the display
/// socket that is exposed to the wayland client.
///
/// # Parameters
/// - `kernel`: The kernel that the server is running in.
/// - `executor`: The `fasync::Executor` to use when serving the view provider protocol.
/// - `display_socket`: The socket that exposed to the wayland client as the display socket.
/// - `outgoing_dir_channel`: The channel endpoint to serve the outgoing directory on.
/// - `wayland_server_channel`: The channel endpoint that is handed to the wayland bridge.
/// - `wayland_bridge`: The channel endpoint that this server will use to communicate with the
///                     wayland bridge.
/// - `view_producer`: The `ViewProducerProxy` which produces a `ViewProvider` that this server
///                    proxies `ViewProvider` requests to.
/// - `wayland_dispatcher`: The `WaylandDispatcherProxy` used to establish a channel connection with
///                         the wayland bridge.
Serves the view-related protocols on behalf of the component that is running.
This function also spawns a thread to proxy data between the wayland bridge and the display
socket that is exposed to the wayland client.
Serves the view - related protocols on behalf of the component that is running . This function also spawns a thread to proxy data between the wayland bridge and the display socket that is exposed to the wayland client .
fn serve_view_protocols(
    kernel: Weak<Kernel>,
    mut executor: fasync::LocalExecutor,
    display_socket: SocketHandle,
    outgoing_dir_channel: zx::Channel,
    wayland_server_channel: zx::Channel,
    wayland_bridge: zx::Channel,
    view_producer: fwayland::ViewProducerProxy,
    wayland_dispatcher: fvirt::WaylandDispatcherProxy,
) -> Result<(), Error> {
    // Inform the dispatcher of the connected client. This should be done on a per client basis,
    // but for now this assumes that only one wayland client is running in the same starnix
    // instance.
    wayland_dispatcher.on_new_connection(wayland_server_channel)?;
    // Add `ViewProvider` to the exposed services of the component, and then serve the
    // outgoing directory.
    let mut outgoing_dir = ServiceFs::new_local();
    outgoing_dir.dir("svc").add_fidl_service(ExposedServices::ViewProvider);
    outgoing_dir.serve_connection(outgoing_dir_channel)?;
    // Handle communication between the wayland client and wayland bridge.
    let _display_server_thread = std::thread::spawn(move || -> Result<(), Errno> {
        let _executor = fasync::LocalExecutor::new().map_err(|_| errno!(ENOMEM));
        serve_display_socket(kernel, display_socket, wayland_bridge)?;
        Ok(())
    });
    let mut view_producer_events = view_producer.take_event_stream();
    let view_provider = match executor.run_singlethreaded(view_producer_events.next()) {
        Some(Ok(fwayland::ViewProducerEvent::OnNewView { view_provider, id: _id })) => {
            view_provider
                .into_proxy()
                .map_err(|_| anyhow!("Error converting view provider into proxy."))
        }
        _ => Err(anyhow!("Error getting view producer's OnNewView.")),
    }?;
    executor.run_singlethreaded(serve_view_provider(view_provider, outgoing_dir));
    Ok(())
}
fn serve_view_protocols ( kernel : Weak < Kernel > , mut executor : fasync :: LocalExecutor , display_socket : SocketHandle , outgoing_dir_channel : zx :: Channel , wayland_server_channel : zx :: Channel , wayland_bridge : zx :: Channel , view_producer : fwayland :: ViewProducerProxy , wayland_dispatcher : fvirt :: WaylandDispatcherProxy , ) -> Result < ( ) , Error > { // Inform the dispatcher of the connected client. This should be done on a per client basis, // but for now this assumes that only one wayland client is running in the same starnix // instance. wayland_dispatcher . on_new_connection ( wayland_server_channel ) ? ; // Add `ViewProvider` to the exposed services of the component, and then serve the // outgoing directory. let mut outgoing_dir = ServiceFs :: new_local ( ) ; outgoing_dir . dir ( " " ) . add_fidl_service ( ExposedServices :: ViewProvider ) ; outgoing_dir . serve_connection ( outgoing_dir_channel ) ? ; // Handle communication between the wayland client and wayland bridge. let _display_server_thread = std :: thread :: spawn ( move | | -> Result < ( ) , Errno > { let _executor = fasync :: LocalExecutor :: new ( ) . map_err ( | _ | errno ! ( ENOMEM ) ) ; serve_display_socket ( kernel , display_socket , wayland_bridge ) ? ; Ok ( ( ) ) } ) ; let mut view_producer_events = view_producer . take_event_stream ( ) ; let view_provider = match executor . run_singlethreaded ( view_producer_events . next ( ) ) { Some ( Ok ( fwayland :: ViewProducerEvent :: OnNewView { view_provider , id : _id } ) ) => { view_provider . into_proxy ( ) . map_err ( | _ | anyhow ! ( " " ) ) } _ => Err ( anyhow ! ( " " ) ) , } ? ; executor . run_singlethreaded ( serve_view_provider ( view_provider , outgoing_dir ) ) ; Ok ( ( ) ) }
Serves the view-related protocols on behalf of the component that is running.
Serves the view - related protocols on behalf of the component that is running .
kernel
Weak<Kernel>
executor
fasync::LocalExecutor
display_socket
SocketHandle
outgoing_dir_channel
zx::Channel
wayland_server_channel
zx::Channel
wayland_bridge
zx::Channel
view_producer
fwayland::ViewProducerProxy
wayland_dispatcher
fvirt::WaylandDispatcherProxy
kernel
Weak<Kernel>
The kernel that the server is running in.
The kernel that the server is running in .
executor
fasync::LocalExecutor
The `fasync::Executor` to use when serving the view provider protocol.
The ` fasync :: Executor ` to use when serving the view provider protocol .
display_socket
SocketHandle
The socket that exposed to the wayland client as the display socket.
The socket that exposed to the wayland client as the display socket .
outgoing_dir_channel
zx::Channel
The channel endpoint to serve the outgoing directory on.
The channel endpoint to serve the outgoing directory on .
wayland_server_channel
zx::Channel
The channel endpoint that is handed to the wayland bridge.
The channel endpoint that is handed to the wayland bridge .
wayland_bridge
zx::Channel
The channel endpoint that this server will use to communicate with the
wayland bridge.
The channel endpoint that this server will use to communicate with the wayland bridge .
view_producer
fwayland::ViewProducerProxy
The `ViewProducerProxy` which produces a `ViewProvider` that this server
proxies `ViewProvider` requests to.
The ` ViewProducerProxy ` which produces a ` ViewProvider ` that this server proxies ` ViewProvider ` requests to .
wayland_dispatcher
fvirt::WaylandDispatcherProxy
The `WaylandDispatcherProxy` used to establish a channel connection with
the wayland bridge.
The ` WaylandDispatcherProxy ` used to establish a channel connection with the wayland bridge .