Skip to main content

ReportIo

Trait ReportIo 

Source
pub trait ReportIo: Send {
    // Required methods
    fn set_feature(
        &mut self,
        report_id: u8,
        payload: &[u8],
    ) -> Result<(), TransportError>;
    fn get_feature(
        &mut self,
        report_id: u8,
        output: &mut [u8],
    ) -> Result<usize, TransportError>;
    fn write_output(
        &mut self,
        report_id: u8,
        payload: &[u8],
    ) -> Result<(), TransportError>;
    fn read_input(&mut self, output: &mut [u8]) -> Result<usize, TransportError>;
}
Expand description

Synchronous, byte-level report I/O owned by one serialized connection worker.

Semantic operations such as setting DPI or lighting deliberately do not belong in this trait. Platform backends are responsible for report-ID conventions.

此 trait 由单个串行连接任务持有,只负责字节读写;DPI、灯光等语义操作不属于传输层。平台后端处理报文 ID 约定。

Required Methods§

Source

fn set_feature( &mut self, report_id: u8, payload: &[u8], ) -> Result<(), TransportError>

Send a feature payload using the backend’s report-ID convention. 按后端的报文 ID 约定发送 Feature 负载;错误不代表可以安全重试。

Source

fn get_feature( &mut self, report_id: u8, output: &mut [u8], ) -> Result<usize, TransportError>

Read a feature response into the caller’s buffer and return bytes copied. 将 Feature 响应写入调用方缓冲区并返回复制字节数;调用方需校验长度和协议内容。

Source

fn write_output( &mut self, report_id: u8, payload: &[u8], ) -> Result<(), TransportError>

Send an output report. Backends report I/O errors without semantic retries. 发送 Output 报告;后端返回 I/O 错误,不自行进行语义重试。

Source

fn read_input(&mut self, output: &mut [u8]) -> Result<usize, TransportError>

Read an input report and return bytes copied; framing belongs to the backend. 读取 Input 报告并返回复制字节数;报文封装由后端处理。

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§