1.0 redesign: unify parser fallibility — sweep 16 Option parsers to Result + one error model #85
Labels
No labels
blocks-others
breaking
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
license: clean
license: foxio
needs-fuzz
priority: P0
priority: P1
priority: P2
question
roadmap
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
marcpardo/flowscope#85
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Strategic / pre-1.0. Breaking — last chance to fix parser fallibility before the 1.0 lock.
Problem — three return conventions + two error philosophies
parse()return types split three ways across the parsers:Result<T, ParseError>(the #65 sweep — 5 modules):dnp3,ldap,kerberos,quic,smb.crate::Result<T>(unifiedError— 3 modules):icmp(parser.rs:17,28),dns(parser.rs:22,27),layers(mod.rs:278,285).Option<T>(still — 16 modules):arp,cdp,dhcp,modbus,ssh(kexinit),ntp,tftp,ndp,lldp,wireguard,netbios_ns,stun,ssdp,rdp,snmp,radius.So #65 fixed the binary wire parsers but left every Tier-2 protocol parser on
Option— a caller can't tell "not my protocol" from "malformed/truncated."Two error philosophies coexist:
crate::ErrorwithModule+ErrorCode(src/error.rs:62,122,184) used by http/tls/dns/icmp/layers/pcap/reassembler/tracker.ParseError(dnp3/ldap/kerberos/quic/smb) — and those 5 modules are not even in theModuleenum (error.rs:62), so their failures can never be expressed as a unifiedError.ErrorCodealready hasParse/Truncated/Unsupportedvariants that duplicate what the per-module enums re-encode.Proposed direction — pick ONE model for 1.0
Recommended: every fallible parser returns
Result<T, ParseError>with a per-moduleParseErrorthat exposes the operationally-distinct failure modes (the #65 shape — it's strictly more informative thanOption, and "not my protocol" becomes a named variant rather than ambiguousNone). Then:Optionparsers toResultwith a per-moduleParseError(mirror the dnp3/smb pattern:Truncated{need,have}/BadMagic/ protocol-specific variants).Moduleand give everyParseErroraFrom<ParseError> for crate::Errorso both the typed and unified views work (recommended — keeps the rich per-module enum and lets?bubble tocrate::Error), or (b) drop the per-module enums in favor ofcrate::Erroreverywhere. (a) preserves the strong-typing #65 deliberately chose.SessionParser/DatagramParseruse the&mut Vecsink (correct, alloc-free) — this issue is only the freeparse()functions, not the trait. Keep them distinct.Why now
Post-1.0, changing a parser's return type is a hard break behind an extension shim. Pre-1.0 it's a mechanical sweep with a CHANGELOG recipe. This is the last cheap moment.
Relationship: completes #65 (which scoped only 5 modules) and unifies the error story #131 started.
Effort: M (mechanical but touches 16 modules + tests).