Skip to content

Commit 5750f97

Browse files
authored
Rust nigthly & dependency fixes (#15)
* Add rust-toolchain.toml file This file tells cargo (and other tools, like vscode rust-analyzer plugin) to use the nightly toolchain by default. This is needed to correctly open the project in vscode with rust-analyzer. We should probably fix a nigthly version, but for now leave it as a generic `nightly`. * Use feature(generic_associated_types) as in stable The feature(generic_associated_types) has been recently stabilized and does not need to be listed in the `#![feature(...)]` block. Also, move the `where` clauses on GAT impls to after the type assignment, taking advantage of a syntax change described here: rust-lang/rust#89122 * Update bitvec to 1.0.1 bitvec-0.22.3 depends on yanked funty-1.2.0 and no longer builds. Update to bitvec-1.0.1 as this is the most recent version. Change a few API calls as they have been renamed. Move the framebuffer BitArray size to a constant so that it is not repeated. * Fix a typo in settings.toml * Invoke `cargo fmt` on the whole workspace * Fix apex-ctl clap usage and update it Update clap to 4.0.26. Enable the `derive` feature to fix compilation. Change the derive attributes to work with newer version of clap. Drop apex_hardware::FareBuffer use. * Fix `debug` feature Make `src/render/debug.rs` buildable. * Fix `coindesk` section in `settings.toml` It was called `crypto`, but the provider is called `coindesk` instead. * fixup! Update bitvec to 1.0.1
1 parent 4f94270 commit 5750f97

File tree

21 files changed

+75
-90
lines changed

21 files changed

+75
-90
lines changed

apex-ctl/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ edition = "2021"
77

88
[dependencies]
99
anyhow = "1.0.44"
10-
clap = "3.0.0-beta.5"
10+
clap = { version = "4.0.26", features = ["derive"] }
1111
log = "0.4.14"
1212
simplelog = "0.10.2"
1313
apex-hardware = { path = "../apex-hardware", features= ["usb"] }

apex-ctl/src/main.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
use anyhow::Result;
2-
use apex_hardware::{Device, FrameBuffer, USBDevice};
3-
use clap::Parser;
2+
use apex_hardware::{Device, USBDevice};
3+
use clap::{ArgAction, Parser, Subcommand};
44
use log::{info, LevelFilter};
55
use simplelog::{Config as LoggerConfig, SimpleLogger};
66

77
#[derive(Parser)]
88
#[clap(version = "1.0", author = "not-jan")]
99
struct Opts {
1010
/// A level of verbosity, and can be used multiple times
11-
#[clap(short, long, parse(from_occurrences))]
12-
verbose: i32,
13-
#[clap(subcommand)]
11+
#[arg(short, long, action = ArgAction::Count)]
12+
verbose: u8,
13+
#[command(subcommand)]
1414
subcmd: SubCommand,
1515
}
1616

17-
#[derive(Parser)]
17+
#[derive(Subcommand)]
1818
enum SubCommand {
1919
/// Clear the OLED screen
2020
Clear,

apex-engine/src/engine.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ impl AsyncDevice for Engine {
7575
#[allow(clippy::needless_lifetimes)]
7676
fn draw<'this>(&'this mut self, display: &'this FrameBuffer) -> Self::DrawResult<'this> {
7777
async {
78-
let screen = display.framebuffer.as_buffer();
78+
let screen = display.framebuffer.as_raw_slice();
7979

8080
let event = GameEvent {
8181
game: GAME,

apex-engine/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
#![feature(generic_associated_types, type_alias_impl_trait)]
1+
#![feature(type_alias_impl_trait)]
22
mod engine;
33
pub use engine::{Engine, HEARTBEAT, REMOVE_EVENT, REMOVE_GAME};

apex-hardware/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ async = []
1212

1313
[dependencies]
1414
anyhow = "1.0.44"
15-
bitvec = "0.22.3"
15+
bitvec = "1.0.1"
1616
embedded-graphics = "0.7.1"
1717
hidapi = { version = "1.2.6", optional = true }
1818
num_enum = "0.5.4"

apex-hardware/src/device.rs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,22 @@ use embedded_graphics::{pixelcolor::BinaryColor, prelude::*};
44
#[cfg(feature = "async")]
55
use std::future::Future;
66

7+
const FB_SIZE: usize = 40 * 128 / 8 + 2;
8+
79
#[derive(Copy, Clone, Debug)]
810
pub struct FrameBuffer {
911
/// The framebuffer with one bit value per pixel.
1012
/// Two extra bytes are added, one for the header byte `0x61` and one for a
1113
/// trailing null byte. This is done to prevent superfluous copies when
1214
/// sending the image to a display device. The implementations of
1315
/// `Drawable` and `DrawTarget` take this quirk into account.
14-
pub framebuffer: BitArray<Msb0, [u8; 40 * 128 / 8 + 2]>,
16+
pub framebuffer: BitArray<[u8; FB_SIZE], Msb0>,
1517
}
1618

1719
impl Default for FrameBuffer {
1820
fn default() -> Self {
19-
let mut framebuffer = BitArray::<Msb0, [u8; 642]>::zeroed();
20-
framebuffer.as_mut_buffer()[0] = 0x61;
21+
let mut framebuffer = BitArray::<[u8; FB_SIZE], Msb0>::ZERO;
22+
framebuffer.as_raw_mut_slice()[0] = 0x61;
2123
FrameBuffer { framebuffer }
2224
}
2325
}
@@ -121,18 +123,15 @@ impl<T: Device> AsyncDevice for T
121123
where
122124
T: 'static,
123125
{
124-
type ClearResult<'a>
126+
type ClearResult<'a> = impl Future<Output = Result<()>> + 'a
125127
where
126-
Self: 'a,
127-
= impl Future<Output = Result<()>> + 'a;
128-
type DrawResult<'a>
128+
Self: 'a;
129+
type DrawResult<'a> = impl Future<Output = Result<()>> + 'a
129130
where
130-
Self: 'a,
131-
= impl Future<Output = Result<()>> + 'a;
132-
type ShutdownResult<'a>
131+
Self: 'a;
132+
type ShutdownResult<'a> = impl Future<Output = Result<()>> + 'a
133133
where
134-
Self: 'a,
135-
= impl Future<Output = Result<()>> + 'a;
134+
Self: 'a;
136135

137136
#[allow(clippy::needless_lifetimes)]
138137
fn draw<'this>(&'this mut self, display: &'this FrameBuffer) -> Self::DrawResult<'this> {

apex-hardware/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![feature(generic_associated_types, type_alias_impl_trait)]
1+
#![feature(type_alias_impl_trait)]
22
mod device;
33
#[cfg(feature = "usb")]
44
mod usb;

apex-hardware/src/usb.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ impl Device for USBDevice {
6666
fn draw(&mut self, display: &FrameBuffer) -> Result<()> {
6767
Ok(self
6868
.handle
69-
.send_feature_report(display.framebuffer.as_buffer())?)
69+
.send_feature_report(display.framebuffer.as_raw_slice())?)
7070
}
7171

7272
fn clear(&mut self) -> Result<()> {

apex-mpris2/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![feature(generic_associated_types, type_alias_impl_trait, async_iterator)]
1+
#![feature(type_alias_impl_trait, async_iterator)]
22
mod generated;
33
mod player;
44
pub use player::{Metadata, Player, MPRIS2};

apex-mpris2/src/player.rs

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -195,22 +195,18 @@ impl<'a> Player<'a> {
195195
impl<'a> AsyncPlayer for Player<'a> {
196196
type Metadata = Metadata;
197197

198-
type MetadataFuture<'b>
198+
type MetadataFuture<'b> = impl Future<Output = Result<Self::Metadata>> + 'b
199199
where
200-
Self: 'b,
201-
= impl Future<Output = Result<Self::Metadata>> + 'b;
202-
type NameFuture<'b>
200+
Self: 'b;
201+
type NameFuture<'b> = impl Future<Output = String> + 'b
203202
where
204-
Self: 'b,
205-
= impl Future<Output = String> + 'b;
206-
type PlaybackStatusFuture<'b>
203+
Self: 'b;
204+
type PlaybackStatusFuture<'b> = impl Future<Output = Result<PlaybackStatus>> + 'b
207205
where
208-
Self: 'b,
209-
= impl Future<Output = Result<PlaybackStatus>> + 'b;
210-
type PositionFuture<'b>
206+
Self: 'b;
207+
type PositionFuture<'b> = impl Future<Output = Result<i64>> + 'b
211208
where
212-
Self: 'b,
213-
= impl Future<Output = Result<i64>> + 'b;
209+
Self: 'b;
214210

215211
#[allow(clippy::needless_lifetimes)]
216212
fn metadata<'this>(&'this self) -> Self::MetadataFuture<'this> {

0 commit comments

Comments
 (0)