Constructor
new WirehairDecoderRaw()
Creates an instance of WirehairDecoderRaw.
Only usable after calling await initWirehairModule().
Consider using WirehairDecoderRaw.create() instead.
- Source:
Classes
Methods
decode(blockId, packetDataU8) → {number|false}
Decodes a received raw packet.
Parameters:
Name | Type | Description |
---|---|---|
blockId |
number | The ID of the block contained in packetDataU8. |
packetDataU8 |
Uint8Array | The raw packet data to decode (payload only). |
- Source:
Throws:
-
If the decoder is not initialized or if packet data is too large.
- Type
- Error
Returns:
The result of the decode operation (e.g., Wirehair_Success, Wirehair_NeedMore).
Returns `false` if the blockId has already been received.
- Type
- number | false
free()
Frees the resources associated with this decoder instance in the WebAssembly module.
Call this method when the decoder is no longer needed to prevent memory leaks.
- Source:
init(messageBytes, packetSize)
Initializes the decoder with the total message size and raw packet (payload) size.
This method must be called before decoding any packets.
Parameters:
Name | Type | Description |
---|---|---|
messageBytes |
number | The total size of the original message in bytes. |
packetSize |
number | The size of each raw data payload. |
- Source:
Throws:
-
If WASM buffer allocation for packet data fails.
- Type
- Error
recover() → {Uint8Array}
Attempts to recover the original message from the decoded packets.
This should be called after enough packets have been successfully decoded
(i.e., when `decode` returns `Wirehair_Success`).
- Source:
Throws:
-
If WASM buffer allocation for the decoded message fails or if recovery fails.
- Type
- Error
Returns:
The recovered original message.
- Type
- Uint8Array
(async, static) create() → {Promise.<WirehairDecoderRaw>}
Asynchronously creates and initializes a WirehairDecoderRaw instance.
Ensures the Wirehair WebAssembly module is initialized before creating the decoder.
- Source:
Returns:
A promise that resolves to a new WirehairDecoderRaw instance.
- Type
- Promise.<WirehairDecoderRaw>