diff --git a/Cargo.toml b/Cargo.toml index b54704f..0fb10b1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "a653rs-postcard" -version = "0.2.0" +version = "0.3.0" edition = "2021" authors = ["Sven Friedrich "] license = "MIT OR Apache-2.0" @@ -12,4 +12,4 @@ serde = { version = "1.0", features = ["derive"], default-features = false } postcard = { version = "1.0", default-features = false } arrayvec = { version = "0.7", default-features = false } -a653rs = "0.4" +a653rs = "0.5" diff --git a/flake.lock b/flake.lock index 5f66aa8..c269704 100644 --- a/flake.lock +++ b/flake.lock @@ -6,11 +6,11 @@ "nixpkgs": "nixpkgs" }, "locked": { - "lastModified": 1660811669, - "narHash": "sha256-V6lmsaLNFz41myppL0yxglta92ijkSvpZ+XVygAh+bU=", + "lastModified": 1705332421, + "narHash": "sha256-USpGLPme1IuqG78JNqSaRabilwkCyHmVWY0M9vYyqEA=", "owner": "numtide", "repo": "devshell", - "rev": "c2feacb46ee69949124c835419861143c4016fb5", + "rev": "83cb93d6d063ad290beee669f4badf9914cc16ec", "type": "github" }, "original": { @@ -27,11 +27,11 @@ "rust-analyzer-src": "rust-analyzer-src" }, "locked": { - "lastModified": 1662965863, - "narHash": "sha256-HLJNVthKQLtilC1xpuonhECJO4UZ0+JtIDwozqhwko4=", + "lastModified": 1706595721, + "narHash": "sha256-nf5/lPawM20WO1gHAlsUwDEJ4v+InC3BYYV1EBsBJZk=", "owner": "nix-community", "repo": "fenix", - "rev": "ad632ed546a3c33b64505ca0dba262f46082d73e", + "rev": "46a368edf5f1cc16573157797e5acead834d5b2c", "type": "github" }, "original": { @@ -41,12 +41,15 @@ } }, "flake-utils": { + "inputs": { + "systems": "systems" + }, "locked": { - "lastModified": 1642700792, - "narHash": "sha256-XqHrk7hFb+zBvRg6Ghl+AZDq03ov6OshJLiSWOoX5es=", + "lastModified": 1701680307, + "narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=", "owner": "numtide", "repo": "flake-utils", - "rev": "846b2ae0fc4cc943637d3d1def4454213e203cba", + "rev": "4022d587cbbfd70fe950c1e2083a02621806a725", "type": "github" }, "original": { @@ -57,11 +60,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1643381941, - "narHash": "sha256-pHTwvnN4tTsEKkWlXQ8JMY423epos8wUOhthpwJjtpc=", + "lastModified": 1704161960, + "narHash": "sha256-QGua89Pmq+FBAro8NriTuoO/wNaUtugt29/qqA8zeeM=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "5efc8ca954272c4376ac929f4c5ffefcc20551d5", + "rev": "63143ac2c9186be6d9da6035fa22620018c85932", "type": "github" }, "original": { @@ -73,10 +76,12 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 0, - "narHash": "sha256-50235YW76Jnx4okogoJv/sMz+WNnqC+0DqtkV3jm2XM=", - "path": "/nix/store/aw7bxjysi3wd3xia5qh7qqwsbqmyqbya-source", - "type": "path" + "lastModified": 1704732714, + "narHash": "sha256-ABqK/HggMYA/jMUXgYyqVAcQ8QjeMyr1jcXfTpSHmps=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "6723fa4e4f1a30d42a633bef5eb01caeb281adc3", + "type": "github" }, "original": { "id": "nixpkgs", @@ -94,11 +99,11 @@ "rust-analyzer-src": { "flake": false, "locked": { - "lastModified": 1662896065, - "narHash": "sha256-1LkSsXzI1JTAmP/GMTz4fTJd8y/tw8R79l96q+h7mu8=", + "lastModified": 1706540258, + "narHash": "sha256-6RTztJE21l0hfWHp0qMWBurWnoFmUxYEDCvaGTnQYcA=", "owner": "rust-lang", "repo": "rust-analyzer", - "rev": "2e9f1204ca01c3e20898d4a67c8b84899d394a88", + "rev": "d13951f25c4cb880bff09a3c02a796ecc51f69ac", "type": "github" }, "original": { @@ -108,13 +113,46 @@ "type": "github" } }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_2": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, "utils": { + "inputs": { + "systems": "systems_2" + }, "locked": { - "lastModified": 1659877975, - "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", + "lastModified": 1705309234, + "narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=", "owner": "numtide", "repo": "flake-utils", - "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0", + "rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 07e3491..fc99446 100644 --- a/flake.nix +++ b/flake.nix @@ -12,7 +12,7 @@ let pkgs = import nixpkgs { inherit system; - overlays = [ devshell.overlay ]; + overlays = [ devshell.overlays.default ]; }; rust-toolchain = with fenix.packages.${system}; combine [ diff --git a/src/queuing.rs b/src/queuing.rs index b9b9bbe..d0274e1 100644 --- a/src/queuing.rs +++ b/src/queuing.rs @@ -13,7 +13,10 @@ pub trait QueuingPortSenderExt { } pub trait QueuingPortReceiverExt { - fn recv_type(&self, timeout: SystemTime) -> Result> + fn recv_type( + &self, + timeout: SystemTime, + ) -> Result<(T, QueueOverflow), QueuingRecvError> where T: for<'a> Deserialize<'a>, [u8; MSG_SIZE as usize]:; @@ -40,16 +43,19 @@ impl(&self, timeout: SystemTime) -> Result> + fn recv_type( + &self, + timeout: SystemTime, + ) -> Result<(T, QueueOverflow), QueuingRecvError> where T: for<'a> Deserialize<'a>, { let mut msg_buf = [0u8; MSG_SIZE as usize]; - let msg = self.receive(&mut msg_buf, timeout)?; + let (msg, overflow) = self.receive(&mut msg_buf, timeout)?; let msg_slice = DeSlice::new(msg); let mut deserializer = postcard::Deserializer::from_flavor(msg_slice); match T::deserialize(&mut deserializer) { - Ok(t) => Ok(t), + Ok(t) => Ok((t, overflow)), Err(e) => { let mut msg = ArrayVec::from(msg_buf); msg.truncate(msg.len());