feat: add documentation, unit tests, integration tests, and CI workflows#2
Merged
tmthecoder merged 10 commits intomainfrom Feb 8, 2026
Merged
feat: add documentation, unit tests, integration tests, and CI workflows#2tmthecoder merged 10 commits intomainfrom
tmthecoder merged 10 commits intomainfrom
Conversation
7b24290 to
8e5838f
Compare
…d CI workflows - Add rustdoc to key public modules (lib, protocol, header, body, message) - Add inline #[cfg(test)] unit tests to 11 source files covering: byte_helper, header, flags, command_code, dialect, capabilities, security_mode, filetime, error_response, empty/echo, message - Move doc comments above #[derive] to fix proc-macro tag serialization - Create smbclient-based integration tests (tests/smbclient.rs) - Add GitHub Actions workflows: check, unit-tests, integration-tests, docs Test results: 47 passed, 4 expected failures (known bugs: u64 bit-shift 54 vs 56, error_response parse always returns UnknownError, filetime round-trip depends on buggy u64 helpers)
- smb-core, smb-derive, smb: edition 2021 → 2024 - Restore let-chains syntax in smb-derive/src/field.rs (stable in 2024) - Remove explicit `ref` in match patterns (implicit in 2024) - smb-derive/src/field_mapping.rs - smb/src/server/message_handler.rs
- Fix StringTag::smb_from_bytes using relative offset as absolute index - Fix Vector::smb_to_bytes alignment closure hardcoding 8 instead of align param - Fix smb_enum_from_bytes NamedStruct arm missing #variant_ident interpolation - Fix ByteTag::smb_from_bytes missing bounds check (panic → Err on malformed input) - Fix SMBString::smb_to_bytes UTF-16 length using UTF-8 byte count instead of UTF-16 byte count - Fix encode_utf16() iterator not collected in string serialization - Remove all debug println! statements (compile-time and runtime) - Add rustdoc to all 4 creator modules (FromBytes, ToBytes, ByteSize, EnumFromBytes) - Add rustdoc to all attribute structs and field mapping types - Add 25 integration tests covering all derive macros and field attribute types - Add smb-core and num_enum as dev-dependencies for test support
a3441e6 to
dba7bfa
Compare
- smb-core: replace needless .as_bytes().len() with .len() on String - smb-derive: prefix unused variables with underscore - smb-derive: allow dead_code on DiscriminatedEnum variant - smb-derive: elide needless explicit lifetimes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
#[cfg(test)]) added to 11 source files covering: byte_helper, header, flags, command_code, dialect, capabilities, security_mode, filetime, error_response, empty/echo, message#[derive]to prevent proc-macro tag serialization breakagetests/smbclient.rs) — 6 ignored tests for negotiate, session setup, tree connect, and resiliencesmb-derive: Macro Correctness & Documentation
SMBFromBytes,SMBToBytes,SMBByteSize,SMBEnumFromBytes) and all field attribute types (smb_direct,smb_buffer,smb_vector,smb_string,smb_enum,smb_skip,smb_byte_tag,smb_string_tag,smb_discriminator)StringTag::smb_from_bytes—position()returns relative offset but was used as absolute index instarts_withVector::smb_to_bytes— alignment closure hardcoded8instead of using thealignparametersmb_enum_from_bytesNamedStruct arm — emitted literalvariant_identinstead of interpolating#variant_identByteTag::smb_from_bytes— no bounds check before scanning; panics instead of returningErron malformed inputSMBString::smb_to_bytes— used UTF-8.len()for the wire length field instead ofencode_utf16().count() * 2SMBString::smb_to_bytes—encode_utf16()iterator was not collected before iterationprintln!statements (3 compile-time, 1 runtime)Known remaining macro limitations (documented in tests with workarounds)
smb_byte_tag/smb_string_tag) generate broken variable references inSMBToBytesself.val_0instead ofself.0inSMBToBytesTest Results
47 passed, 4 expected failures documenting known bugs:
byte_helper: bit shift 54 instead of 56 for u64 high byteerror_response:smb_from_bytesalways returnsUnknownErrorfiletime: round-trip broken due to buggy u64 helperssmb-derive: 25 passed, 0 failed