From caaacc6778e42b7ee664147d4195e3a1fbfd7ec4 Mon Sep 17 00:00:00 2001 From: Samuel Tardieu <sam@rfc1149.net> Date: Sat, 21 Sep 2024 13:08:31 +0200 Subject: [PATCH] Mark `Controller::get_encoder_ticks()` as deprecated in Rust API --- Cargo.lock | 13 +++++++++++++ tele0592/Cargo.toml | 1 + tele0592/examples/check-firmware.rs | 1 + tele0592/src/controller.rs | 4 ++++ 4 files changed, 19 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index d2f0670..fc7d38c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -438,6 +438,18 @@ dependencies = [ "defmt", ] +[[package]] +name = "deprecate-until" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a3767f826efbbe5a5ae093920b58b43b01734202be697e1354914e862e8e704" +dependencies = [ + "proc-macro2", + "quote", + "semver 1.0.23", + "syn 2.0.77", +] + [[package]] name = "document-features" version = "0.2.10" @@ -1295,6 +1307,7 @@ name = "tele0592" version = "1.1.1" dependencies = [ "color-eyre", + "deprecate-until", "embedded-hal 1.0.0", "micromath", "rppal", diff --git a/tele0592/Cargo.toml b/tele0592/Cargo.toml index 03a34ec..7776ccc 100644 --- a/tele0592/Cargo.toml +++ b/tele0592/Cargo.toml @@ -14,6 +14,7 @@ readme = "README.md" exclude = [".envrc", "default.nix"] [dependencies] +deprecate-until = "0.1.1" embedded-hal = "1.0.0" micromath = { version = "2.1.0", optional = true } diff --git a/tele0592/examples/check-firmware.rs b/tele0592/examples/check-firmware.rs index 7c7a341..0eaaaa0 100644 --- a/tele0592/examples/check-firmware.rs +++ b/tele0592/examples/check-firmware.rs @@ -2,6 +2,7 @@ use color_eyre::eyre::Context; use std::{thread, time::Duration}; use tele0592::{Controller as _, Device as _}; +#[allow(clippy::too_many_lines, deprecated)] // deprecated needed for c.get_encoder_ticks() fn main() -> color_eyre::Result<()> { color_eyre::install()?; let mut c = rppal::i2c::I2c::with_bus(8).with_context(|| "opening I²C bus")?; diff --git a/tele0592/src/controller.rs b/tele0592/src/controller.rs index a368407..0d71eb3 100644 --- a/tele0592/src/controller.rs +++ b/tele0592/src/controller.rs @@ -240,6 +240,10 @@ pub trait Controller: Device { /// /// # Errors /// This method may fail if the communication with the board fails. + #[deprecate_until::deprecate_until( + remove = ">= 2.x", + note = "use `Controller::get_relative_encoder_ticks()` instead" + )] fn get_encoder_ticks(&mut self) -> Result<(i16, i16), Self::I2cError> { let mut buf = [0; 4]; self.write_read([CMD_ENCODER_TICKS], &mut buf)?; -- GitLab