Expand description
Contains all the type and interfaces for the parser sub-crates.
The parsing system in socketioxide is split in three phases for serialization and deserialization:
§Deserialization
- The SocketIO server receives a packet and calls
Parse::decode_str
orParse::decode_bin
to decode the incoming packet. If aParseError::NeedsMoreBinaryData
is returned, the server keeps the packet and waits for new incoming data. - Once the packet is complete, the server dispatches the packet to the appropriate namespace
and calls
Parse::read_event
to route the data to the appropriate event handler. - If the user-provided handler has a
Data
extractor with a providedT
type, the server callsParse::decode_value
to deserialize the data. This function will handle the event name as the first argument of the array, as well as variadic arguments.
§Serialization
- The user calls emit from the socket or namespace with custom
Serializable
data. The server callsParse::encode_value
to convert this to a rawValue
to be included in the packet. The function will take care of handling the event name as the first argument of the array, along with variadic arguments. - The server then calls
Parse::encode
to convert the payload provided by the user, along with other metadata (namespace, ack ID, etc.), into a fully serialized packet ready to be sent.
Structs§
- First
Element - A seed that can be used to deserialize only the 1st element of a sequence
- Parser
Error - A parser error that wraps any error that can occur during parsing.
- Parser
State - The parser state that is shared between the parser and the socket.io system. Used to handle partial binary packets when receiving binary packets that have adjacent binary attachments
Enums§
- Parse
Error - Errors when parsing/serializing socket.io packets
Traits§
- Parse
- All socket.io parser should implement this trait. Parsers should be stateless.
Functions§
- is_
de_ tuple - Returns true if the type is a tuple-like type according to the serde model.
- is_
ser_ tuple - Returns true if the value is a tuple-like type according to the serde model.