25 Commits

Author SHA1 Message Date
f9a72fe9a3 feat(message): add support for decoding messages with trailing data
Added a new parameter `allow_too_long` to `Protocol300Message::try_from_bytes` to optionally ignore trailing data when decoding messages. This is useful when receiving messages with extra bytes that should not cause decoding to fail.

- Updated function signature and documentation to include the new parameter
- Modified length validation logic to skip error when `allow_too_long` is true
- Updated all existing test cases to use the new parameter
- Added new test cases to verify behavior with and without trailing data
2026-01-18 21:08:54 +01:00
025331989f feat(transmission): add support for incomplete Protocol 300 messages
Add `try_from_bytes_incomplete` method to handle Protocol 300 transmissions that may contain extra trailing bytes. This improves robustness when parsing messages from unreliable sources or when dealing with partial data.

The original `try_from_bytes` method remains strict, while the new method provides a more lenient parsing option for cases where strict validation isn't required. Also added a TODO comment for future validation of message length.
2026-01-18 19:23:18 +01:00
881b83c597 fix alloc 2026-01-18 19:20:13 +01:00
ad9ca06bda fix(transmission): avoid lifetime in FromBytesError by owning data
Changed FromBytesError::InvalidBytes to take ownership of the byte slice by converting it to Vec<u8>. This removes the lifetime parameter from the enum, simplifying the API and preventing potential lifetime-related issues. The change ensures that error instances can be freely moved and stored without borrowing constraints.
2026-01-18 19:19:06 +01:00
9072ae01ad feat(transmission): improve error handling for invalid byte sequences
Refactored Protocol300Transmission parsing to provide more detailed error information when encountering invalid byte sequences. Changed the error variant from `InvalidByte` to `InvalidBytes` which now includes the problematic byte slice, enabling better debugging. Updated the match arm to capture the byte slice as `b` instead of using a wildcard, and modified the error logging to reflect these changes. The lifetime parameter was added to the `FromBytesError` enum to support the byte slice reference.
2026-01-18 19:16:03 +01:00
7e3d16ad6a feat(transmission): add length_in_bytes method to Protocol300Transmission
Add a new method to calculate the byte length of Protocol300Transmission
variants without converting to bytes. The method returns:
- 1 byte for control characters (Ack, Enq, Eot, Nack)
- 3 bytes for Init
- telegram_length + 3 bytes for Message

Include comprehensive unit tests for all transmission variants to ensure
correct length calculation.
2026-01-17 18:47:25 +01:00
034d06bf46 Add errors to public use 2026-01-17 14:52:03 +01:00
e3ba418251 add from bytes error to exported 2026-01-17 14:41:37 +01:00
6ca19f88fa Added defmt logging 2026-01-16 22:33:53 +01:00
d30a261e74 Add better error logging 2026-01-16 22:17:13 +01:00
40fa67ecea fix no-std compatiblity 2026-01-10 17:39:04 +01:00
ffc7ed4a0e Added Protocol300Transmission to also decode control codes 2026-01-10 17:33:48 +01:00
0c29ee4e8b fixed alloc 2026-01-06 15:47:45 +01:00
1ab2c0e18f no chrono lol 2026-01-06 15:40:39 +01:00
2b7253d41b fix str 2026-01-06 15:37:50 +01:00
65f17e7b01 Test 2026-01-06 15:34:46 +01:00
7d27e6337c Added create response message functions 2026-01-03 20:16:51 +01:00
b3274e942c added display 2025-12-07 17:20:41 +01:00
04ab5e2c4c added display 2025-12-07 17:13:35 +01:00
a000c0854b Changes 2025-12-07 16:50:10 +01:00
c2b9eaa8d3 add no-std 2025-12-06 22:30:42 +01:00
f3b79bb9aa added expected return 2025-11-22 00:16:09 +01:00
48ecc063bf pub use more stuff 2025-11-16 22:12:02 +01:00
4b8073c614 Implemented all 2025-11-11 22:39:18 +01:00
1ce1537487 Initial 2025-11-10 13:31:32 +01:00