socketioxide icon indicating copy to clipboard operation
socketioxide copied to clipboard

Feat custom parser

Open Totodore opened this issue 1 year ago • 0 comments

Motivation

Modify the codebase to have a flexible way to handle new parsers. Close issue #234.

Solution

A new Parse trait with a parser module will contain all the parser implementations. Each implementations will implement the Parse trait. They will be enumerated in a Parser enum. Therefore the branching on the chosen parsen will be done with static enum dispatch. The CommonParser will be the default parser as for the official socket.io implementation.

A future improvement might be to have a better and flexible Value type throughout the codebase in order to handle all the different parsers case we might implement. This might also allow the usage of https://docs.rs/serde_json/latest/serde_json/value/struct.RawValue.html for serde_json which would avoid many useless allocations.

Totodore avatar Jul 23 '24 19:07 Totodore