Skip to content

Commit d2bf2d8

Browse files
committed
update ci and deps
1 parent e636a82 commit d2bf2d8

File tree

8 files changed

+48
-53
lines changed

8 files changed

+48
-53
lines changed

.github/bors.toml

-24
This file was deleted.

.github/workflows/ci.yml

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
on:
2-
push:
3-
branches: [ staging, trying, master ]
4-
pull_request:
2+
push: # Run CI for all branches except GitHub merge queue tmp branches
3+
branches-ignore:
4+
- "gh-readonly-queue/**"
5+
pull_request: # Run CI for PRs on any branch
6+
merge_group: # Run CI for the GitHub merge queue
57

68
name: Build
79

@@ -16,24 +18,24 @@ jobs:
1618
rust: [stable]
1719
TARGET:
1820
- aarch64-unknown-linux-gnu
21+
- aarch64-unknown-linux-musl
1922
- arm-unknown-linux-gnueabi
23+
- arm-unknown-linux-gnueabihf
2024
- armv7-unknown-linux-gnueabihf
2125
- i686-unknown-linux-gnu
2226
- i686-unknown-linux-musl
23-
- mips-unknown-linux-gnu
24-
- mips64-unknown-linux-gnuabi64
25-
- mips64el-unknown-linux-gnuabi64
26-
- mipsel-unknown-linux-gnu
27+
# - loongarch64-unknown-linux-gnu
2728
- powerpc-unknown-linux-gnu
2829
# - powerpc64-unknown-linux-gnu
2930
- powerpc64le-unknown-linux-gnu
31+
- riscv64gc-unknown-linux-gnu
3032
- s390x-unknown-linux-gnu
3133
- x86_64-unknown-linux-gnu
3234
- x86_64-unknown-linux-musl
3335

3436
include:
3537
# MSRV
36-
- rust: 1.59.0
38+
- rust: 1.65.0
3739
TARGET: x86_64-unknown-linux-gnu
3840

3941
# Test nightly but don't fail
@@ -63,15 +65,13 @@ jobs:
6365
args: --target=${{ matrix.TARGET }} --all-features
6466

6567
- name: Test
66-
if: ${{ ! contains(matrix.TARGET, 'mips') }} # https://github.com/rust-lang/rust/issues/108835
6768
uses: actions-rs/cargo@v1
6869
with:
6970
use-cross: true
7071
command: test
7172
args: --target=${{ matrix.TARGET }}
7273

7374
- name: Test all features
74-
if: ${{ ! contains(matrix.TARGET, 'mips') }} # https://github.com/rust-lang/rust/issues/108835
7575
uses: actions-rs/cargo@v1
7676
with:
7777
use-cross: true
@@ -109,7 +109,7 @@ jobs:
109109
- uses: actions-rs/toolchain@v1
110110
with:
111111
profile: minimal
112-
toolchain: 1.59.0
112+
toolchain: 1.65.0
113113
components: clippy
114114

115115
- uses: actions-rs/clippy-check@v1

CHANGELOG.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ Versioning](https://semver.org/spec/v2.0.0.html).
88

99
## [Unreleased]
1010

11-
- MSRV is now 1.59.0.
11+
- Updated nix to version `0.27`.
12+
- Updated bitflags to version `2.4`.
13+
- MSRV is now 1.65.0.
1214

1315
## [v0.5.1] - 2021-11-22
1416

Cargo.toml

+3-2
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ name = "async_tokio"
2020
required-features = ["async-tokio"]
2121

2222
[dependencies]
23-
bitflags = "1.3"
23+
bitflags = "2.4"
2424
libc = "0.2"
25-
nix = "0.23"
25+
nix = { version = "0.27", features = ["ioctl"] }
2626
tokio = { version = "1", features = ["io-std", "net"], optional = true }
2727
futures = { version = "0.3", optional = true }
2828

@@ -31,6 +31,7 @@ quicli = "0.4"
3131
structopt = "0.3"
3232
anyhow = "1.0"
3333
tokio = { version = "1", features = ["io-std", "rt-multi-thread", "macros", "net"] }
34+
nix = { version = "0.27", features = ["ioctl", "poll"] }
3435

3536
[package.metadata.docs.rs]
3637
# To build locally:

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ to be considered reliable.
206206

207207
## Minimum Supported Rust Version (MSRV)
208208

209-
This crate is guaranteed to compile on stable Rust 1.59.0 and up. It *might*
209+
This crate is guaranteed to compile on stable Rust 1.65.0 and up. It *might*
210210
compile with older versions but that may change in any new patch release.
211211

212212
## License

examples/monitor.rs

+7-8
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
use gpio_cdev::*;
1010
use nix::poll::*;
1111
use quicli::prelude::*;
12-
use std::os::unix::io::AsRawFd;
12+
use std::os::unix::io::{AsRawFd, FromRawFd, OwnedFd};
1313
use structopt::StructOpt;
1414

1515
type PollEventFlags = nix::poll::PollFlags;
@@ -41,14 +41,13 @@ fn do_main(args: Cli) -> anyhow::Result<()> {
4141
.collect();
4242

4343
// Create a vector of file descriptors for polling
44-
let mut pollfds: Vec<PollFd> = evt_handles
44+
let ownedfd: Vec<OwnedFd> = evt_handles
4545
.iter()
46-
.map(|h| {
47-
PollFd::new(
48-
h.as_raw_fd(),
49-
PollEventFlags::POLLIN | PollEventFlags::POLLPRI,
50-
)
51-
})
46+
.map(|h| unsafe { OwnedFd::from_raw_fd(h.as_raw_fd()) })
47+
.collect();
48+
let mut pollfds: Vec<PollFd> = ownedfd
49+
.iter()
50+
.map(|fd| PollFd::new(fd, PollEventFlags::POLLIN | PollEventFlags::POLLPRI))
5251
.collect();
5352

5453
loop {

src/async_tokio.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,6 @@ impl Stream for AsyncLineEventHandle {
9797

9898
impl AsRef<LineEventHandle> for AsyncLineEventHandle {
9999
fn as_ref(&self) -> &LineEventHandle {
100-
&self.asyncfd.get_ref()
100+
self.asyncfd.get_ref()
101101
}
102102
}

src/lib.rs

+22-5
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ use std::fs::{read_dir, File, ReadDir};
9595
use std::io::Read;
9696
use std::mem;
9797
use std::ops::Index;
98-
use std::os::unix::io::{AsRawFd, FromRawFd, RawFd};
98+
use std::os::unix::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, RawFd};
9999
use std::path::{Path, PathBuf};
100100
use std::ptr;
101101
use std::slice;
@@ -335,7 +335,7 @@ pub struct Line {
335335
/// Wraps kernel [`struct gpioline_info`].
336336
///
337337
/// [`struct gpioline_info`]: https://elixir.bootlin.com/linux/v4.9.127/source/include/uapi/linux/gpio.h#L36
338-
#[derive(Debug, Clone)]
338+
#[derive(Debug)]
339339
pub struct LineInfo {
340340
line: Line,
341341
flags: LineFlags,
@@ -349,6 +349,7 @@ bitflags! {
349349
/// Maps to kernel [`GPIOHANDLE_REQUEST_*`] flags.
350350
///
351351
/// [`GPIOHANDLE_REQUEST_*`]: https://elixir.bootlin.com/linux/v4.9.127/source/include/uapi/linux/gpio.h#L58
352+
#[derive(Debug, Clone)]
352353
pub struct LineRequestFlags: u32 {
353354
const INPUT = (1 << 0);
354355
const OUTPUT = (1 << 1);
@@ -367,7 +368,7 @@ bitflags! {
367368
pub struct EventRequestFlags: u32 {
368369
const RISING_EDGE = (1 << 0);
369370
const FALLING_EDGE = (1 << 1);
370-
const BOTH_EDGES = Self::RISING_EDGE.bits | Self::FALLING_EDGE.bits;
371+
const BOTH_EDGES = Self::RISING_EDGE.bits() | Self::FALLING_EDGE.bits();
371372
}
372373
}
373374

@@ -377,6 +378,7 @@ bitflags! {
377378
/// Maps to kernel [`GPIOLINE_FLAG_*`] flags.
378379
///
379380
/// [`GPIOLINE_FLAG_*`]: https://elixir.bootlin.com/linux/v4.9.127/source/include/uapi/linux/gpio.h#L29
381+
#[derive(Debug)]
380382
pub struct LineFlags: u32 {
381383
const KERNEL = (1 << 0);
382384
const IS_OUT = (1 << 1);
@@ -572,7 +574,7 @@ impl Line {
572574
consumer: &str,
573575
) -> Result<AsyncLineEventHandle> {
574576
let events = self.events(handle_flags, event_flags, consumer)?;
575-
Ok(AsyncLineEventHandle::new(events)?)
577+
AsyncLineEventHandle::new(events)
576578
}
577579
}
578580

@@ -693,7 +695,7 @@ impl LineHandle {
693695

694696
/// Get the flags with which this handle was created
695697
pub fn flags(&self) -> LineRequestFlags {
696-
self.flags
698+
self.flags.clone()
697699
}
698700
}
699701

@@ -985,6 +987,14 @@ impl LineEventHandle {
985987
&self.line
986988
}
987989

990+
pub fn file(&self) -> &File {
991+
&self.file
992+
}
993+
994+
pub fn file2(&mut self) -> &File {
995+
&self.file
996+
}
997+
988998
/// Helper function which returns the line event if a complete event was read, Ok(None) if not
989999
/// enough data was read or the error returned by `read()`.
9901000
pub(crate) fn read_event(&mut self) -> std::io::Result<Option<LineEvent>> {
@@ -1011,6 +1021,13 @@ impl AsRawFd for LineEventHandle {
10111021
}
10121022
}
10131023

1024+
impl AsFd for LineEventHandle {
1025+
/// Gets the raw file descriptor for the `LineEventHandle`.
1026+
fn as_fd(&self) -> BorrowedFd<'_> {
1027+
self.file.as_fd()
1028+
}
1029+
}
1030+
10141031
impl Iterator for LineEventHandle {
10151032
type Item = Result<LineEvent>;
10161033

0 commit comments

Comments
 (0)