From 2b74fef9cff1d8126a6e61bda81d1a782491b1c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Stu=CC=88rmer?= Date: Fri, 4 Oct 2024 18:02:15 +0200 Subject: [PATCH] add no_std --- Cargo.lock | 57 -------------------------------------------- Cargo.toml | 4 +--- src/aps/error.rs | 5 ++++ src/aps/mod.rs | 6 +---- src/aps/types/mod.rs | 6 +++-- src/lib.rs | 2 ++ 6 files changed, 13 insertions(+), 67 deletions(-) create mode 100644 src/aps/error.rs diff --git a/Cargo.lock b/Cargo.lock index fbc284e..4880747 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5,69 +5,12 @@ name = "bitmaps" version = "3.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "proc-macro2" -version = "1.0.86" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "unicode-ident 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "quote" -version = "1.0.37" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 1.0.86 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "serde" -version = "1.0.210" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "serde_derive 1.0.210 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "serde_derive" -version = "1.0.210" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 1.0.86 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 2.0.79 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "syn" -version = "2.0.79" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 1.0.86 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-ident 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "unicode-ident" -version = "1.0.13" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "zigbee-rs" version = "0.1.0" dependencies = [ "bitmaps 3.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.210 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.210 (registry+https://github.com/rust-lang/crates.io-index)", ] [metadata] "checksum bitmaps 3.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a1d084b0137aaa901caf9f1e8b21daa6aa24d41cd806e111335541eff9683bd6" -"checksum proc-macro2 1.0.86 (registry+https://github.com/rust-lang/crates.io-index)" = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" -"checksum quote 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)" = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" -"checksum serde 1.0.210 (registry+https://github.com/rust-lang/crates.io-index)" = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a" -"checksum serde_derive 1.0.210 (registry+https://github.com/rust-lang/crates.io-index)" = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" -"checksum syn 2.0.79 (registry+https://github.com/rust-lang/crates.io-index)" = "89132cd0bf050864e1d38dc3bbc07a0eb8e7530af26344d3d2bbbef83499f590" -"checksum unicode-ident 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)" = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" diff --git a/Cargo.toml b/Cargo.toml index 847d493..03821a7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,7 +16,5 @@ license = "MIT OR Apache-2.0" [dependencies] -bitmaps = "3.2.1" -serde = "1" -serde_derive = "1" +bitmaps = { version = "3.2.1", default-features = false } diff --git a/src/aps/error.rs b/src/aps/error.rs new file mode 100644 index 0000000..c8d9db2 --- /dev/null +++ b/src/aps/error.rs @@ -0,0 +1,5 @@ +pub(crate) enum ApsError { + // Value is not within the valid range + InvalidValue, +} + diff --git a/src/aps/mod.rs b/src/aps/mod.rs index fe5cdae..f792b39 100644 --- a/src/aps/mod.rs +++ b/src/aps/mod.rs @@ -1,7 +1,6 @@ #![allow(dead_code)] -use serde_derive::{Serialize, Deserialize}; - +mod error; mod types; trait ApsdeSap { @@ -26,7 +25,6 @@ struct ApsdeSapRequest { radius_counter: u8 } -#[derive(Serialize, Deserialize)] enum ApsdeSapConfirmStatus { Success, NoShortAddress, @@ -45,13 +43,11 @@ struct ApsdeSapConfirm { tx_time: u8, } -#[derive(Serialize, Deserialize)] enum ApsdeSapIndicationStatus { Success, DefragUnsupported, DefragDeferred } -#[derive(Serialize, Deserialize)] enum SecurityStatus { Unsecured, SecuredNwkKey, diff --git a/src/aps/types/mod.rs b/src/aps/types/mod.rs index 1d8cdc3..9600ade 100644 --- a/src/aps/types/mod.rs +++ b/src/aps/types/mod.rs @@ -1,15 +1,17 @@ //! Bounded address //! 2.2.4.1.1 + +use super::error::ApsError; pub struct SrcEndpoint { value: u8 } impl SrcEndpoint { - pub fn new(value: u8) -> Result { + pub fn new(value: u8) -> Result { if value <= 254 { Ok(SrcEndpoint { value }) } else { - Err(format!("Value {} is not within the valid range 0x00 – 0xfe", value)) + Err(ApsError::InvalidValue) } } } diff --git a/src/lib.rs b/src/lib.rs index cf9f15f..e63ed43 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,3 +1,5 @@ +#![no_std] + //! # zigbee //! //! ZigBee is a protocol stack based on the ZigBee specification 22 1.0