Skip to content

Commit

Permalink
Merge pull request project-chip#119 from ivmarkov/rust-stable
Browse files Browse the repository at this point in the history
Switch to stable Rust, remove the `nightly` feature
  • Loading branch information
kedars committed Jan 8, 2024
2 parents f42dbab + e7991d6 commit 370035e
Show file tree
Hide file tree
Showing 12 changed files with 49 additions and 64 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/ci-tlv-tool.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,20 @@ on:
workflow_dispatch:

env:
RUST_TOOLCHAIN: stable
CARGO_TERM_COLOR: always

jobs:
build_tlv_tool:
runs-on: ubuntu-latest

steps:
- name: Rust
uses: dtolnay/rust-toolchain@v1
with:
toolchain: ${{ env.RUST_TOOLCHAIN }}
components: rustfmt, clippy, rust-src

- name: Checkout
uses: actions/checkout@v3

Expand Down
12 changes: 5 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
workflow_dispatch:

env:
RUST_TOOLCHAIN: nightly
RUST_TOOLCHAIN: stable
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CARGO_TERM_COLOR: always

Expand All @@ -21,11 +21,9 @@ jobs:
matrix:
crypto-backend: ['rustcrypto', 'mbedtls', 'openssl']
features: ['', 'alloc', 'os']
toolchain: ['stable', 'nightly']

steps:
- name: Rust
if: matrix.toolchain == 'nightly'
uses: dtolnay/rust-toolchain@v1
with:
toolchain: ${{ env.RUST_TOOLCHAIN }}
Expand All @@ -35,14 +33,14 @@ jobs:
uses: actions/checkout@v3

- name: Fmt
run: cargo +${{ matrix.toolchain == 'nightly' && env.RUST_TOOLCHAIN || 'stable'}} fmt -- --check
run: cargo fmt -- --check

- name: Clippy
run: cargo +${{ matrix.toolchain == 'nightly' && env.RUST_TOOLCHAIN || 'stable'}} clippy --no-deps --no-default-features --features ${{matrix.crypto-backend}},${{matrix.features}},${{ matrix.toolchain == 'nightly' && 'nightly' || ''}} -- -Dwarnings
run: cargo clippy --no-deps --no-default-features --features ${{matrix.crypto-backend}},${{matrix.features}} -- -Dwarnings

- name: Build
run: cargo +${{ matrix.toolchain == 'nightly' && env.RUST_TOOLCHAIN || 'stable'}} build --no-default-features --features ${{matrix.crypto-backend}},${{matrix.features}},${{ matrix.toolchain == 'nightly' && 'nightly' || ''}}
run: cargo build --no-default-features --features ${{matrix.crypto-backend}},${{matrix.features}}

- name: Test
if: matrix.features == 'os'
run: cargo +${{ matrix.toolchain == 'nightly' && env.RUST_TOOLCHAIN || 'stable'}} test --no-default-features --features ${{matrix.crypto-backend}},${{matrix.features}},${{ matrix.toolchain == 'nightly' && 'nightly' || ''}} -- --test-threads=1
run: cargo test --no-default-features --features ${{matrix.crypto-backend}},${{matrix.features}}
7 changes: 7 additions & 0 deletions .github/workflows/publish-dry-run.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,20 @@ name: PublishDryRun
on: workflow_dispatch

env:
RUST_TOOLCHAIN: stable
CRATE_NAME: rs-matter

jobs:
publish_dry_run:
name: PublishDryRun
runs-on: ubuntu-latest
steps:
- name: Rust
uses: dtolnay/rust-toolchain@v1
with:
toolchain: ${{ env.RUST_TOOLCHAIN }}
components: rustfmt, clippy, rust-src

- name: Checkout
uses: actions/checkout@v3

Expand Down
9 changes: 9 additions & 0 deletions .github/workflows/publish-macros-dry-run.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,20 @@ name: PublishMacrosDryRun

on: workflow_dispatch

env:
RUST_TOOLCHAIN: stable

jobs:
publish_macros_dry_run:
name: PublishMacrosDryRun
runs-on: ubuntu-latest
steps:
- name: Rust
uses: dtolnay/rust-toolchain@v1
with:
toolchain: ${{ env.RUST_TOOLCHAIN }}
components: rustfmt, clippy, rust-src

- name: Checkout
uses: actions/checkout@v3

Expand Down
9 changes: 9 additions & 0 deletions .github/workflows/publish-macros.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,20 @@ name: PublishMacros

on: workflow_dispatch

env:
RUST_TOOLCHAIN: stable

jobs:
publish_macros:
name: PublishMacros
runs-on: ubuntu-latest
steps:
- name: Rust
uses: dtolnay/rust-toolchain@v1
with:
toolchain: ${{ env.RUST_TOOLCHAIN }}
components: rustfmt, clippy, rust-src

- name: Checkout
uses: actions/checkout@v3

Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,20 @@ name: Publish
on: workflow_dispatch

env:
RUST_TOOLCHAIN: stable
CRATE_NAME: rs-matter

jobs:
publish:
name: Publish
runs-on: ubuntu-latest
steps:
- name: Rust
uses: dtolnay/rust-toolchain@v1
with:
toolchain: ${{ env.RUST_TOOLCHAIN }}
components: rustfmt, clippy, rust-src

- name: Checkout
uses: actions/checkout@v3

Expand Down
2 changes: 1 addition & 1 deletion rs-matter/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ readme = "README.md"
keywords = ["matter", "smart", "smart-home", "IoT", "ESP32"]
categories = ["embedded", "network-programming"]
license = "Apache-2.0"
rust-version = "1.75"

[features]
default = ["os", "mbedtls"]
Expand All @@ -17,7 +18,6 @@ esp-idf = ["std", "rustcrypto", "esp-idf-sys"]
std = ["alloc", "rand", "async-io", "esp-idf-sys?/std", "embassy-time/generic-queue-16"]
backtrace = []
alloc = []
nightly = []
openssl = ["alloc", "dep:openssl", "foreign-types", "hmac", "sha2"]
mbedtls = ["alloc", "dep:mbedtls"]
rustcrypto = ["alloc", "sha2", "hmac", "pbkdf2", "hkdf", "aes", "ccm", "p256", "elliptic-curve", "crypto-bigint", "x509-cert", "rand_core"]
Expand Down
4 changes: 0 additions & 4 deletions rs-matter/src/data_model/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,8 @@ impl<T> DataModel<T> {
#[cfg(not(feature = "alloc"))]
let interaction = &mut interaction;

#[cfg(feature = "nightly")]
let metadata = self.0.lock().await;

#[cfg(not(feature = "nightly"))]
let metadata = self.0.lock();

if interaction.start().await? {
match interaction {
Interaction::Read {
Expand Down
39 changes: 3 additions & 36 deletions rs-matter/src/data_model/objects/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,18 +133,7 @@ impl<'a, 'b, 'c> AttrDataEncoder<'a, 'b, 'c> {
Ok(attr) => {
let encoder = AttrDataEncoder::new(attr, tw);

let result = {
#[cfg(not(feature = "nightly"))]
{
handler.read(attr, encoder)
}

#[cfg(feature = "nightly")]
{
handler.read(attr, encoder).await
}
};

let result = handler.read(attr, encoder).await;
match result {
Ok(()) => None,
Err(e) => {
Expand Down Expand Up @@ -173,18 +162,7 @@ impl<'a, 'b, 'c> AttrDataEncoder<'a, 'b, 'c> {
) -> Result<(), Error> {
let status = match item {
Ok((attr, data)) => {
let result = {
#[cfg(not(feature = "nightly"))]
{
handler.write(attr, AttrData::new(attr.dataver, data))
}

#[cfg(feature = "nightly")]
{
handler.write(attr, AttrData::new(attr.dataver, data)).await
}
};

let result = handler.write(attr, AttrData::new(attr.dataver, data)).await;
match result {
Ok(()) => attr.status(IMStatusCode::Success)?,
Err(error) => attr.status(error.into())?,
Expand Down Expand Up @@ -347,18 +325,7 @@ impl<'a, 'b, 'c> CmdDataEncoder<'a, 'b, 'c> {
let mut tracker = CmdDataTracker::new();
let encoder = CmdDataEncoder::new(cmd, &mut tracker, tw);

let result = {
#[cfg(not(feature = "nightly"))]
{
handler.invoke(exchange, cmd, data, encoder)
}

#[cfg(feature = "nightly")]
{
handler.invoke(exchange, cmd, data, encoder).await
}
};

let result = handler.invoke(exchange, cmd, data, encoder).await;
match result {
Ok(()) => cmd.success(&tracker),
Err(error) => {
Expand Down
9 changes: 0 additions & 9 deletions rs-matter/src/data_model/objects/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,9 @@ use crate::{

use super::{AttrData, AttrDataEncoder, AttrDetails, CmdDataEncoder, CmdDetails};

#[cfg(feature = "nightly")]
pub use asynch::*;

#[cfg(not(feature = "nightly"))]
pub trait DataModelHandler: super::Metadata + Handler {}
#[cfg(not(feature = "nightly"))]
impl<T> DataModelHandler for T where T: super::Metadata + Handler {}

#[cfg(feature = "nightly")]
pub trait DataModelHandler: super::asynch::AsyncMetadata + asynch::AsyncHandler {}
#[cfg(feature = "nightly")]
impl<T> DataModelHandler for T where T: super::asynch::AsyncMetadata + asynch::AsyncHandler {}

pub trait ChangeNotifier<T> {
Expand Down Expand Up @@ -294,7 +286,6 @@ macro_rules! handler_chain_type {
};
}

#[cfg(feature = "nightly")]
mod asynch {
use crate::{
data_model::objects::{AttrData, AttrDataEncoder, AttrDetails, CmdDataEncoder, CmdDetails},
Expand Down
2 changes: 0 additions & 2 deletions rs-matter/src/data_model/objects/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

use crate::data_model::objects::Node;

#[cfg(feature = "nightly")]
pub use asynch::*;

use super::HandlerCompat;
Expand Down Expand Up @@ -120,7 +119,6 @@ where
}
}

#[cfg(feature = "nightly")]
pub mod asynch {
use crate::data_model::objects::{HandlerCompat, Node};

Expand Down
6 changes: 1 addition & 5 deletions rs-matter/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,7 @@
//!
//! Start off exploring by going to the [Matter] object.
#![cfg_attr(not(feature = "std"), no_std)]
#![allow(stable_features)]
#![allow(unknown_lints)]
#![cfg_attr(feature = "nightly", feature(async_fn_in_trait))]
#![cfg_attr(feature = "nightly", allow(async_fn_in_trait))]
#![cfg_attr(feature = "nightly", feature(impl_trait_projections))]
#![allow(async_fn_in_trait)]

pub mod acl;
pub mod cert;
Expand Down

0 comments on commit 370035e

Please sign in to comment.