Skip to content

Remove NodeType::Unexpected.#12

Open
explodes wants to merge 1 commit into
nimrodshn:masterfrom
explodes:explodes/remove-unexpected-node-type
Open

Remove NodeType::Unexpected.#12
explodes wants to merge 1 commit into
nimrodshn:masterfrom
explodes:explodes/remove-unexpected-node-type

Conversation

@explodes
Copy link
Copy Markdown

@explodes explodes commented Apr 11, 2026

The enum NodeType::Unexpected is only created when parsing possibly bad data.

By creating an error state before creating the unexpected NodeType, we can remove this type from the code altogether, resulting in fewer branches throughout the rest of the library.

When encountering the bad data, a new error is returned: Error::InvalidData.

The pub trait: From<u8> for NodeType is removed.
The pub trait: TryFrom<u8> for NodeType is added.
The pub enum Error::InvalidData is added.
Fixes #11

This node type was only created when parsing possibly bad data.
By creating an error state before creating the unexpected NodeType, we can
remove this type from the code altogether, resulting in fewer branches
throughout the rest of the library.
@explodes explodes marked this pull request as ready for review April 11, 2026 11:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove NodeType::Unexpected

1 participant