/// Sends any data that can be read out of `socket` to `wayland_channel`.
///
/// Ancillary data of type `UnixControlData::Rights` is converted to the appropriate handle before
/// sending them off to the wayland bridge.
Sends any data that can be read out of `socket` to `wayland_channel`.
Ancillary data of type `UnixControlData::Rights` is converted to the appropriate handle before
sending them off to the wayland bridge.
Sends any data that can be read out of ` socket ` to ` wayland_channel ` . Ancillary data of type ` UnixControlData :: Rights ` is converted to the appropriate handle before sending them off to the wayland bridge .
fn send_to_wayland(socket: &Socket, wayland_channel: &mut zx::Channel) -> Result<(), Errno> {
    let messages = socket.read_kernel();
    for message in messages {
        let mut handles = vec![];
        if let Some(ancillary_data) = message.ancillary_data {
            match ancillary_data {
                AncillaryData::Unix(UnixControlData::Rights(files)) => {
                    for file in files {
                        if let Some(f) = file.downcast_file::<BufferCollectionFile>() {
                            handles.push(
                                f.token
                                    .value
                                    .as_handle_ref()
                                    .duplicate(zx::Rights::SAME_RIGHTS)
                                    .expect("Failed to duplicate buffer collection import token."),
                            );
                        }
                    }
                }
                _ => {
                    log::error!("Got unexpected ancillary data.");
                    return error!(ENOSYS);
                }
            }
        }
        wayland_channel
            .write(message.data.bytes(), &mut handles)
            .map_err(|e| from_status_like_fdio!(e))?;
    }
    Ok(())
}
fn send_to_wayland ( socket : & Socket , wayland_channel : & mut zx :: Channel ) -> Result < ( ) , Errno > { let messages = socket . read_kernel ( ) ; for message in messages { let mut handles = vec ! [ ] ; if let Some ( ancillary_data ) = message . ancillary_data { match ancillary_data { AncillaryData :: Unix ( UnixControlData :: Rights ( files ) ) => { for file in files { if let Some ( f ) = file . downcast_file :: < BufferCollectionFile > ( ) { handles . push ( f . token . value . as_handle_ref ( ) . duplicate ( zx :: Rights :: SAME_RIGHTS ) . expect ( " " ) , ) ; } } } _ => { log :: error ! ( " " ) ; return error ! ( ENOSYS ) ; } } } wayland_channel . write ( message . data . bytes ( ) , & mut handles ) . map_err ( | e | from_status_like_fdio ! ( e ) ) ? ; } Ok ( ( ) ) }
Sends any data that can be read out of `socket` to `wayland_channel`.
Sends any data that can be read out of ` socket ` to ` wayland_channel ` .
socket
&Socket
wayland_channel
&mut zx::Channel