Skip to content

Commit

Permalink
update ci and deps
Browse files Browse the repository at this point in the history
  • Loading branch information
Dirreke committed Aug 31, 2023
1 parent e636a82 commit 06ee939
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 28 deletions.
11 changes: 6 additions & 5 deletions .github/bors.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,22 @@ delete_merged_branches = true
required_approvals = 1
status = [
"build (stable, aarch64-unknown-linux-gnu)",
"build (stable, aarch64-unknown-linux-musl)",
"build (stable, arm-unknown-linux-gnueabi)",
"build (stable, arm-unknown-linux-gnueabihf)",
"build (stable, armv7-unknown-linux-gnueabihf)",
"build (stable, i686-unknown-linux-gnu)",
"build (stable, i686-unknown-linux-musl)",
"build (stable, mips-unknown-linux-gnu)",
"build (stable, mips64-unknown-linux-gnuabi64)",
"build (stable, mips64el-unknown-linux-gnuabi64)",
"build (stable, mipsel-unknown-linux-gnu)",
# "build (stable, loongarch64-unknown-linux-gnu)",
"build (stable, powerpc-unknown-linux-gnu)",
# "build (stable, powerpc64-unknown-linux-gnu)",
"build (stable, powerpc64le-unknown-linux-gnu)",
"build (stable, riscv64gc-unknown-linux-gnu)",
"build (stable, s390x-unknown-linux-gnu)",
"build (stable, x86_64-unknown-linux-gnu)",
"build (stable, x86_64-unknown-linux-musl)",

"build (1.59.0, x86_64-unknown-linux-gnu)",
"build (1.65.0, x86_64-unknown-linux-gnu)",

"checks"
]
Expand Down
14 changes: 6 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,24 @@ jobs:
rust: [stable]
TARGET:
- aarch64-unknown-linux-gnu
- aarch64-unknown-linux-musl
- arm-unknown-linux-gnueabi
- arm-unknown-linux-gnueabihf
- armv7-unknown-linux-gnueabihf
- i686-unknown-linux-gnu
- i686-unknown-linux-musl
- mips-unknown-linux-gnu
- mips64-unknown-linux-gnuabi64
- mips64el-unknown-linux-gnuabi64
- mipsel-unknown-linux-gnu
# - loongarch64-unknown-linux-gnu
- powerpc-unknown-linux-gnu
# - powerpc64-unknown-linux-gnu
- powerpc64le-unknown-linux-gnu
- riscv64gc-unknown-linux-gnu
- s390x-unknown-linux-gnu
- x86_64-unknown-linux-gnu
- x86_64-unknown-linux-musl

include:
# MSRV
- rust: 1.59.0
- rust: 1.65.0
TARGET: x86_64-unknown-linux-gnu

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

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

- name: Test all features
if: ${{ ! contains(matrix.TARGET, 'mips') }} # https://github.com/rust-lang/rust/issues/108835
uses: actions-rs/cargo@v1
with:
use-cross: true
Expand Down Expand Up @@ -109,7 +107,7 @@ jobs:
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: 1.59.0
toolchain: 1.65.0
components: clippy

- uses: actions-rs/clippy-check@v1
Expand Down
5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ name = "async_tokio"
required-features = ["async-tokio"]

[dependencies]
bitflags = "1.3"
bitflags = "2.4"
libc = "0.2"
nix = "0.23"
nix = { version = "0.27", features = ["ioctl"] }
tokio = { version = "1", features = ["io-std", "net"], optional = true }
futures = { version = "0.3", optional = true }

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

[package.metadata.docs.rs]
# To build locally:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ to be considered reliable.

## Minimum Supported Rust Version (MSRV)

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

## License
Expand Down
17 changes: 9 additions & 8 deletions examples/monitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
use gpio_cdev::*;
use nix::poll::*;
use quicli::prelude::*;
use std::os::unix::io::AsRawFd;
use std::os::unix::io::{AsRawFd, FromRawFd};
use std::os::fd::OwnedFd;
use structopt::StructOpt;

type PollEventFlags = nix::poll::PollFlags;
Expand Down Expand Up @@ -41,15 +42,15 @@ fn do_main(args: Cli) -> anyhow::Result<()> {
.collect();

// Create a vector of file descriptors for polling
let mut pollfds: Vec<PollFd> = evt_handles
let ownedfd: Vec<OwnedFd> = evt_handles
.iter()
.map(|h| {
PollFd::new(
h.as_raw_fd(),
PollEventFlags::POLLIN | PollEventFlags::POLLPRI,
)
})
.map(|h| unsafe { OwnedFd::from_raw_fd(h.as_raw_fd()) })
.collect();
let mut pollfds: Vec<PollFd> = ownedfd
.iter()
.map(|fd| {
PollFd::new(fd, PollEventFlags::POLLIN | PollEventFlags::POLLPRI)
}).collect();

loop {
// poll for an event on any of the lines
Expand Down
25 changes: 21 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ extern crate bitflags;
#[macro_use]
extern crate nix;

use std::cmp::min;
use std::{cmp::min, os::fd::{BorrowedFd, AsFd}};

Check failure on line 92 in src/lib.rs

View workflow job for this annotation

GitHub Actions / build (1.65.0, x86_64-unknown-linux-gnu)

unresolved imports `std::os::fd::BorrowedFd`, `std::os::fd::AsFd`

Check failure on line 92 in src/lib.rs

View workflow job for this annotation

GitHub Actions / build (1.65.0, x86_64-unknown-linux-gnu)

module `fd` is private
use std::ffi::CStr;
use std::fs::{read_dir, File, ReadDir};
use std::io::Read;
Expand Down Expand Up @@ -335,7 +335,7 @@ pub struct Line {
/// Wraps kernel [`struct gpioline_info`].
///
/// [`struct gpioline_info`]: https://elixir.bootlin.com/linux/v4.9.127/source/include/uapi/linux/gpio.h#L36
#[derive(Debug, Clone)]
#[derive(Debug)]
pub struct LineInfo {
line: Line,
flags: LineFlags,
Expand All @@ -349,6 +349,7 @@ bitflags! {
/// Maps to kernel [`GPIOHANDLE_REQUEST_*`] flags.
///
/// [`GPIOHANDLE_REQUEST_*`]: https://elixir.bootlin.com/linux/v4.9.127/source/include/uapi/linux/gpio.h#L58
#[derive(Debug, Clone)]
pub struct LineRequestFlags: u32 {
const INPUT = (1 << 0);
const OUTPUT = (1 << 1);
Expand All @@ -367,7 +368,7 @@ bitflags! {
pub struct EventRequestFlags: u32 {
const RISING_EDGE = (1 << 0);
const FALLING_EDGE = (1 << 1);
const BOTH_EDGES = Self::RISING_EDGE.bits | Self::FALLING_EDGE.bits;
const BOTH_EDGES = Self::RISING_EDGE.bits() | Self::FALLING_EDGE.bits();
}
}

Expand All @@ -377,6 +378,7 @@ bitflags! {
/// Maps to kernel [`GPIOLINE_FLAG_*`] flags.
///
/// [`GPIOLINE_FLAG_*`]: https://elixir.bootlin.com/linux/v4.9.127/source/include/uapi/linux/gpio.h#L29
#[derive(Debug)]
pub struct LineFlags: u32 {
const KERNEL = (1 << 0);
const IS_OUT = (1 << 1);
Expand Down Expand Up @@ -693,7 +695,7 @@ impl LineHandle {

/// Get the flags with which this handle was created
pub fn flags(&self) -> LineRequestFlags {
self.flags
self.flags.clone()
}
}

Expand Down Expand Up @@ -985,6 +987,14 @@ impl LineEventHandle {
&self.line
}

pub fn file(&self) -> &File {
&self.file
}

pub fn file2(&mut self) -> &File {
&self.file
}

/// Helper function which returns the line event if a complete event was read, Ok(None) if not
/// enough data was read or the error returned by `read()`.
pub(crate) fn read_event(&mut self) -> std::io::Result<Option<LineEvent>> {
Expand All @@ -1011,6 +1021,13 @@ impl AsRawFd for LineEventHandle {
}
}

impl AsFd for LineEventHandle {
/// Gets the raw file descriptor for the `LineEventHandle`.
fn as_fd(&self) -> BorrowedFd<'_> {
self.file.as_fd()
}
}

impl Iterator for LineEventHandle {
type Item = Result<LineEvent>;

Expand Down

0 comments on commit 06ee939

Please sign in to comment.