Skip to content

Commit

Permalink
Merge pull request #6 from DLR-FT/dev/no-const-expr
Browse files Browse the repository at this point in the history
Remove const expression
  • Loading branch information
wucke13 authored Jun 14, 2024
2 parents 6bf1c90 + c43b9c4 commit a36b5f4
Show file tree
Hide file tree
Showing 11 changed files with 916 additions and 104 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/nix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ jobs:
command:
- verify-no_std
- verify-doc
- verify-features
- verify-tests
steps:
- uses: actions/checkout@v2
- name: Install Nix
Expand Down
22 changes: 19 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,25 @@ license = "MIT OR Apache-2.0"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[features]
default = []
alloc = ["postcard/alloc"]

[dependencies]
serde = { version = "1.0", features = ["derive"], default-features = false }
serde.workspace = true
postcard = { version = "1.0", default-features = false }
arrayvec = { version = "0.7", default-features = false }
a653rs.workspace = true

[dev-dependencies]
a653rs = { workspace = true, features = ["bindings"] }
serde = { workspace = true, features = ["alloc"] }

[package.metadata.cargo-all-features]
skip_optional_dependencies = true

[package.metadata."docs.rs"]
all-features = true

a653rs = "0.5"
[workspace.dependencies]
a653rs = "0.6"
serde = { version = "1.0", default-features = false}
38 changes: 20 additions & 18 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 26 additions & 4 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
utils.url = "github:numtide/flake-utils";
devshell.url = "github:numtide/devshell";
fenix.url = "github:nix-community/fenix";
Expand All @@ -16,11 +17,11 @@
};
rust-toolchain = with fenix.packages.${system};
combine [
latest.rustc
latest.cargo
latest.clippy
stable.rustc
stable.cargo
stable.clippy
latest.rustfmt
targets.thumbv6m-none-eabi.latest.rust-std
targets.thumbv6m-none-eabi.stable.rust-std
];
in
rec {
Expand All @@ -34,6 +35,7 @@
cargo-outdated
cargo-audit
cargo-udeps
cargo-all-features
cargo-watch
nixpkgs-fmt
];
Expand Down Expand Up @@ -82,6 +84,26 @@
"Verify that the documentation builds without problems";
category = "test";
}
{
name = "verify-features";
command = ''
cd $PRJ_ROOT
cargo check-all-features $@
'';
help =
"Verify that all feature combinations build";
category = "test";
}
{
name = "verify-tests";
command = ''
cd $PRJ_ROOT
cargo test-all-features $@
'';
help =
"Verify that all tests run for all feature combinations";
category = "test";
}
];
});
checks = {
Expand Down
77 changes: 54 additions & 23 deletions src/error.rs
Original file line number Diff line number Diff line change
@@ -1,46 +1,77 @@
//! Error Types
#[cfg(feature = "alloc")]
use alloc::vec::Vec;

#[cfg(feature = "alloc")]
extern crate alloc;

use a653rs::prelude::*;
use arrayvec::ArrayVec;

#[cfg(feature = "alloc")]
#[derive(Debug, Clone)]
pub enum QueuingRecvError<const MSG_SIZE: MessageSize>
where
[u8; MSG_SIZE as usize]:,
{
pub enum QueuingRecvError {
Apex(a653rs::prelude::Error),
Postcard(postcard::Error, ArrayVec<u8, { MSG_SIZE as usize }>),
/// Postcard deserialization error
///
/// Also returns the data which failed to deserialize
Postcard(postcard::Error, Vec<u8>),
}

impl<const MSG_SIZE: MessageSize> From<a653rs::prelude::Error> for QueuingRecvError<MSG_SIZE>
where
[u8; MSG_SIZE as usize]:,
{
#[cfg(feature = "alloc")]
impl From<a653rs::prelude::Error> for QueuingRecvError {
fn from(e: a653rs::prelude::Error) -> Self {
QueuingRecvError::Apex(e)
}
}

#[derive(Debug, Clone)]
pub enum SamplingRecvError<const MSG_SIZE: MessageSize>
where
[u8; MSG_SIZE as usize]:,
{
pub enum QueuingRecvBufError<'a> {
Apex(a653rs::prelude::Error),
Postcard(
postcard::Error,
Validity,
ArrayVec<u8, { MSG_SIZE as usize }>,
),
/// Postcard deserialization error
///
/// Also returns the data which failed to deserialize
Postcard(postcard::Error, &'a [u8]),
}

impl<const MSG_SIZE: MessageSize> From<a653rs::prelude::Error> for SamplingRecvError<MSG_SIZE>
where
[u8; MSG_SIZE as usize]:,
{
impl From<a653rs::prelude::Error> for QueuingRecvBufError<'_> {
fn from(e: a653rs::prelude::Error) -> Self {
QueuingRecvBufError::Apex(e)
}
}

#[cfg(feature = "alloc")]
#[derive(Debug, Clone)]
pub enum SamplingRecvError {
Apex(a653rs::prelude::Error),
/// Postcard deserialization error
///
/// Also returns the data which failed to deserialize and its [`Validity`]
Postcard(postcard::Error, Validity, Vec<u8>),
}

#[cfg(feature = "alloc")]
impl From<a653rs::prelude::Error> for SamplingRecvError {
fn from(e: a653rs::prelude::Error) -> Self {
SamplingRecvError::Apex(e)
}
}

#[derive(Debug, Clone)]
pub enum SamplingRecvBufError<'a> {
Apex(a653rs::prelude::Error),
/// Postcard deserialization error
///
/// Also returns the data which failed to deserialize and its [`Validity`]
Postcard(postcard::Error, Validity, &'a [u8]),
}

impl From<a653rs::prelude::Error> for SamplingRecvBufError<'_> {
fn from(e: a653rs::prelude::Error) -> Self {
SamplingRecvBufError::Apex(e)
}
}

#[derive(Debug)]
pub enum SendError {
Apex(a653rs::prelude::Error),
Expand Down
3 changes: 0 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
#![no_std]
// #![deny(missing_docs)]
#![allow(incomplete_features)]
#![feature(generic_const_exprs)]
#![deny(rustdoc::broken_intra_doc_links)]

pub mod error;
Expand Down
2 changes: 2 additions & 0 deletions src/prelude.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Convenience prelude for simple import
pub use crate::error::*;
pub use crate::queuing::*;
pub use crate::sampling::*;
Loading

0 comments on commit a36b5f4

Please sign in to comment.