Skip to content

Commit

Permalink
Lint code and add CI
Browse files Browse the repository at this point in the history
  • Loading branch information
emeric-martineau committed Dec 3, 2023
1 parent a69a5b0 commit 7f56a86
Show file tree
Hide file tree
Showing 5 changed files with 273 additions and 209 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/rust_ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Continuous Integration

on:
push:
paths-ignore:
- "**/README.md"
pull_request:
workflow_dispatch:

env:
CARGO_TERM_COLOR: always
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
rust-checks:
name: Rust Checks
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
action:
- command: build
args: --release
- command: fmt
args: --all -- --check --color always
- command: clippy
args: --all-targets --all-features --workspace -- -D warnings
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Enable caching
uses: Swatinem/rust-cache@v2
- name: Setup Rust
uses: esp-rs/[email protected]
with:
default: true
buildtargets: esp32
ldproxy: true
- name: Run command
run: cargo ${{ matrix.action.command }} ${{ matrix.action.args }}
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "jsy_mk_194"
version = "0.1.0"
version = "1.0.0"
authors = ["Emeric Martineau <[email protected]>"]
edition = "2021"
resolver = "2"
Expand Down
17 changes: 6 additions & 11 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub enum UartErrorKind {
#[derive(Debug, Clone)]
pub struct UartError {
pub message: String,
pub kind: UartErrorKind
pub kind: UartErrorKind,
}

impl fmt::Display for UartError {
Expand All @@ -28,31 +28,28 @@ impl fmt::Display for UartError {

impl UartError {
pub fn new(kind: UartErrorKind, message: String) -> Self {
Self {
message,
kind
}
Self { message, kind }
}

pub fn from(kind: UartErrorKind) -> Self {
Self {
message: String::new(),
kind
kind,
}
}

pub fn other(message: String) -> Self {
Self {
message,
kind: UartErrorKind::Other
kind: UartErrorKind::Other,
}
}
}

/// Error return by change bitrate
#[derive(Debug, Clone)]
pub struct ChangeBitrateError {
pub parent: UartError
pub parent: UartError,
}

impl fmt::Display for ChangeBitrateError {
Expand All @@ -63,8 +60,6 @@ impl fmt::Display for ChangeBitrateError {

impl ChangeBitrateError {
pub fn new(parent: UartError) -> Self {
Self {
parent
}
Self { parent }
}
}
Loading

0 comments on commit 7f56a86

Please sign in to comment.