usb-hid: all the RequestHandler method accept &mut self

This commit is contained in:
Boris Faure 2024-04-15 19:53:46 +02:00
parent 9341ef3b47
commit ae4fb433ae
8 changed files with 24 additions and 24 deletions

View File

@ -378,7 +378,7 @@ pub trait RequestHandler {
/// Reads the value of report `id` into `buf` returning the size. /// Reads the value of report `id` into `buf` returning the size.
/// ///
/// Returns `None` if `id` is invalid or no data is available. /// Returns `None` if `id` is invalid or no data is available.
fn get_report(&self, id: ReportId, buf: &mut [u8]) -> Option<usize> { fn get_report(&mut self, id: ReportId, buf: &mut [u8]) -> Option<usize> {
let _ = (id, buf); let _ = (id, buf);
None None
} }
@ -394,7 +394,7 @@ pub trait RequestHandler {
/// If `id` is `None`, get the idle rate for all reports. Returning `None` /// If `id` is `None`, get the idle rate for all reports. Returning `None`
/// will reject the control request. Any duration at or above 1.024 seconds /// will reject the control request. Any duration at or above 1.024 seconds
/// or below 4ms will be returned as an indefinite idle rate. /// or below 4ms will be returned as an indefinite idle rate.
fn get_idle_ms(&self, id: Option<ReportId>) -> Option<u32> { fn get_idle_ms(&mut self, id: Option<ReportId>) -> Option<u32> {
let _ = id; let _ = id;
None None
} }
@ -403,7 +403,7 @@ pub trait RequestHandler {
/// ///
/// If `id` is `None`, set the idle rate of all input reports to `dur`. If /// If `id` is `None`, set the idle rate of all input reports to `dur`. If
/// an indefinite duration is requested, `dur` will be set to `u32::MAX`. /// an indefinite duration is requested, `dur` will be set to `u32::MAX`.
fn set_idle_ms(&self, id: Option<ReportId>, duration_ms: u32) { fn set_idle_ms(&mut self, id: Option<ReportId>, duration_ms: u32) {
let _ = (id, duration_ms); let _ = (id, duration_ms);
} }
} }

View File

@ -148,7 +148,7 @@ async fn main(_spawner: Spawner) {
struct MyRequestHandler {} struct MyRequestHandler {}
impl RequestHandler for MyRequestHandler { impl RequestHandler for MyRequestHandler {
fn get_report(&self, id: ReportId, _buf: &mut [u8]) -> Option<usize> { fn get_report(&mut self, id: ReportId, _buf: &mut [u8]) -> Option<usize> {
info!("Get report for {:?}", id); info!("Get report for {:?}", id);
None None
} }
@ -158,11 +158,11 @@ impl RequestHandler for MyRequestHandler {
OutResponse::Accepted OutResponse::Accepted
} }
fn set_idle_ms(&self, id: Option<ReportId>, dur: u32) { fn set_idle_ms(&mut self, id: Option<ReportId>, dur: u32) {
info!("Set idle rate for {:?} to {:?}", id, dur); info!("Set idle rate for {:?} to {:?}", id, dur);
} }
fn get_idle_ms(&self, id: Option<ReportId>) -> Option<u32> { fn get_idle_ms(&mut self, id: Option<ReportId>) -> Option<u32> {
info!("Get idle rate for {:?}", id); info!("Get idle rate for {:?}", id);
None None
} }

View File

@ -105,7 +105,7 @@ async fn main(_spawner: Spawner) {
struct MyRequestHandler {} struct MyRequestHandler {}
impl RequestHandler for MyRequestHandler { impl RequestHandler for MyRequestHandler {
fn get_report(&self, id: ReportId, _buf: &mut [u8]) -> Option<usize> { fn get_report(&mut self, id: ReportId, _buf: &mut [u8]) -> Option<usize> {
info!("Get report for {:?}", id); info!("Get report for {:?}", id);
None None
} }
@ -115,11 +115,11 @@ impl RequestHandler for MyRequestHandler {
OutResponse::Accepted OutResponse::Accepted
} }
fn set_idle_ms(&self, id: Option<ReportId>, dur: u32) { fn set_idle_ms(&mut self, id: Option<ReportId>, dur: u32) {
info!("Set idle rate for {:?} to {:?}", id, dur); info!("Set idle rate for {:?} to {:?}", id, dur);
} }
fn get_idle_ms(&self, id: Option<ReportId>) -> Option<u32> { fn get_idle_ms(&mut self, id: Option<ReportId>) -> Option<u32> {
info!("Get idle rate for {:?}", id); info!("Get idle rate for {:?}", id);
None None
} }

View File

@ -125,7 +125,7 @@ async fn main(_spawner: Spawner) {
struct MyRequestHandler {} struct MyRequestHandler {}
impl RequestHandler for MyRequestHandler { impl RequestHandler for MyRequestHandler {
fn get_report(&self, id: ReportId, _buf: &mut [u8]) -> Option<usize> { fn get_report(&mut self, id: ReportId, _buf: &mut [u8]) -> Option<usize> {
info!("Get report for {:?}", id); info!("Get report for {:?}", id);
None None
} }
@ -135,11 +135,11 @@ impl RequestHandler for MyRequestHandler {
OutResponse::Accepted OutResponse::Accepted
} }
fn set_idle_ms(&self, id: Option<ReportId>, dur: u32) { fn set_idle_ms(&mut self, id: Option<ReportId>, dur: u32) {
info!("Set idle rate for {:?} to {:?}", id, dur); info!("Set idle rate for {:?} to {:?}", id, dur);
} }
fn get_idle_ms(&self, id: Option<ReportId>) -> Option<u32> { fn get_idle_ms(&mut self, id: Option<ReportId>) -> Option<u32> {
info!("Get idle rate for {:?}", id); info!("Get idle rate for {:?}", id);
None None
} }

View File

@ -117,7 +117,7 @@ async fn main(_spawner: Spawner) {
struct MyRequestHandler {} struct MyRequestHandler {}
impl RequestHandler for MyRequestHandler { impl RequestHandler for MyRequestHandler {
fn get_report(&self, id: ReportId, _buf: &mut [u8]) -> Option<usize> { fn get_report(&mut self, id: ReportId, _buf: &mut [u8]) -> Option<usize> {
info!("Get report for {:?}", id); info!("Get report for {:?}", id);
None None
} }
@ -127,11 +127,11 @@ impl RequestHandler for MyRequestHandler {
OutResponse::Accepted OutResponse::Accepted
} }
fn set_idle_ms(&self, id: Option<ReportId>, dur: u32) { fn set_idle_ms(&mut self, id: Option<ReportId>, dur: u32) {
info!("Set idle rate for {:?} to {:?}", id, dur); info!("Set idle rate for {:?} to {:?}", id, dur);
} }
fn get_idle_ms(&self, id: Option<ReportId>) -> Option<u32> { fn get_idle_ms(&mut self, id: Option<ReportId>) -> Option<u32> {
info!("Get idle rate for {:?}", id); info!("Get idle rate for {:?}", id);
None None
} }

View File

@ -159,7 +159,7 @@ async fn main(_spawner: Spawner) {
struct MyRequestHandler {} struct MyRequestHandler {}
impl RequestHandler for MyRequestHandler { impl RequestHandler for MyRequestHandler {
fn get_report(&self, id: ReportId, _buf: &mut [u8]) -> Option<usize> { fn get_report(&mut self, id: ReportId, _buf: &mut [u8]) -> Option<usize> {
info!("Get report for {:?}", id); info!("Get report for {:?}", id);
None None
} }
@ -169,11 +169,11 @@ impl RequestHandler for MyRequestHandler {
OutResponse::Accepted OutResponse::Accepted
} }
fn set_idle_ms(&self, id: Option<ReportId>, dur: u32) { fn set_idle_ms(&mut self, id: Option<ReportId>, dur: u32) {
info!("Set idle rate for {:?} to {:?}", id, dur); info!("Set idle rate for {:?} to {:?}", id, dur);
} }
fn get_idle_ms(&self, id: Option<ReportId>) -> Option<u32> { fn get_idle_ms(&mut self, id: Option<ReportId>) -> Option<u32> {
info!("Get idle rate for {:?}", id); info!("Get idle rate for {:?}", id);
None None
} }

View File

@ -126,7 +126,7 @@ async fn main(_spawner: Spawner) {
struct MyRequestHandler {} struct MyRequestHandler {}
impl RequestHandler for MyRequestHandler { impl RequestHandler for MyRequestHandler {
fn get_report(&self, id: ReportId, _buf: &mut [u8]) -> Option<usize> { fn get_report(&mut self, id: ReportId, _buf: &mut [u8]) -> Option<usize> {
info!("Get report for {:?}", id); info!("Get report for {:?}", id);
None None
} }
@ -136,11 +136,11 @@ impl RequestHandler for MyRequestHandler {
OutResponse::Accepted OutResponse::Accepted
} }
fn set_idle_ms(&self, id: Option<ReportId>, dur: u32) { fn set_idle_ms(&mut self, id: Option<ReportId>, dur: u32) {
info!("Set idle rate for {:?} to {:?}", id, dur); info!("Set idle rate for {:?} to {:?}", id, dur);
} }
fn get_idle_ms(&self, id: Option<ReportId>) -> Option<u32> { fn get_idle_ms(&mut self, id: Option<ReportId>) -> Option<u32> {
info!("Get idle rate for {:?}", id); info!("Get idle rate for {:?}", id);
None None
} }

View File

@ -112,7 +112,7 @@ async fn main(_spawner: Spawner) {
struct MyRequestHandler {} struct MyRequestHandler {}
impl RequestHandler for MyRequestHandler { impl RequestHandler for MyRequestHandler {
fn get_report(&self, id: ReportId, _buf: &mut [u8]) -> Option<usize> { fn get_report(&mut self, id: ReportId, _buf: &mut [u8]) -> Option<usize> {
info!("Get report for {:?}", id); info!("Get report for {:?}", id);
None None
} }
@ -122,11 +122,11 @@ impl RequestHandler for MyRequestHandler {
OutResponse::Accepted OutResponse::Accepted
} }
fn set_idle_ms(&self, id: Option<ReportId>, dur: u32) { fn set_idle_ms(&mut self, id: Option<ReportId>, dur: u32) {
info!("Set idle rate for {:?} to {:?}", id, dur); info!("Set idle rate for {:?} to {:?}", id, dur);
} }
fn get_idle_ms(&self, id: Option<ReportId>) -> Option<u32> { fn get_idle_ms(&mut self, id: Option<ReportId>) -> Option<u32> {
info!("Get idle rate for {:?}", id); info!("Get idle rate for {:?}", id);
None None
} }