Skip to content

Commit

Permalink
Merge pull request #74 from Dirreke/fix-ci
Browse files Browse the repository at this point in the history
Fix ci
  • Loading branch information
eldruin authored Sep 7, 2023
2 parents e636a82 + d2bf2d8 commit 6e8a153
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 53 deletions.
24 changes: 0 additions & 24 deletions .github/bors.toml

This file was deleted.

22 changes: 11 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
on:
push:
branches: [ staging, trying, master ]
pull_request:
push: # Run CI for all branches except GitHub merge queue tmp branches
branches-ignore:
- "gh-readonly-queue/**"
pull_request: # Run CI for PRs on any branch
merge_group: # Run CI for the GitHub merge queue

name: Build

Expand All @@ -16,24 +18,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 +65,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 +109,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
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

- MSRV is now 1.59.0.
- Updated nix to version `0.27`.
- Updated bitflags to version `2.4`.
- MSRV is now 1.65.0.

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

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
15 changes: 7 additions & 8 deletions examples/monitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use gpio_cdev::*;
use nix::poll::*;
use quicli::prelude::*;
use std::os::unix::io::AsRawFd;
use std::os::unix::io::{AsRawFd, FromRawFd, OwnedFd};
use structopt::StructOpt;

type PollEventFlags = nix::poll::PollFlags;
Expand Down Expand Up @@ -41,14 +41,13 @@ 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 {
Expand Down
2 changes: 1 addition & 1 deletion src/async_tokio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,6 @@ impl Stream for AsyncLineEventHandle {

impl AsRef<LineEventHandle> for AsyncLineEventHandle {
fn as_ref(&self) -> &LineEventHandle {
&self.asyncfd.get_ref()
self.asyncfd.get_ref()
}
}
27 changes: 22 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ use std::fs::{read_dir, File, ReadDir};
use std::io::Read;
use std::mem;
use std::ops::Index;
use std::os::unix::io::{AsRawFd, FromRawFd, RawFd};
use std::os::unix::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, RawFd};
use std::path::{Path, PathBuf};
use std::ptr;
use std::slice;
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 @@ -572,7 +574,7 @@ impl Line {
consumer: &str,
) -> Result<AsyncLineEventHandle> {
let events = self.events(handle_flags, event_flags, consumer)?;
Ok(AsyncLineEventHandle::new(events)?)
AsyncLineEventHandle::new(events)
}
}

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 6e8a153

Please sign in to comment.