Methods
encode() → {Uint8Array}
Encodes the next block of the message.
- Source:
Throws:
-
If Wirehair encoding fails.
- Type
- Error
Returns:
A packet containing the encoded block data and headers.
The first 4 bytes are messageBytes (total original message size),
the next 4 bytes are the blockId, followed by the encoded data.
- Type
- Uint8Array
setMessage(messageU8, packetSizeWithHeadersopt)
Sets the message to be encoded and initializes the encoder.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
messageU8 |
Uint8Array | The message data as a Uint8Array. | ||
packetSizeWithHeaders |
number |
<optional> |
366 | The desired size of each encoded packet, including headers. This will be adjusted if it's too large for the message. The actual data payload size per packet will be this value minus 8 bytes for headers. |
- Source:
Throws:
-
If WASM buffer allocation fails.
- Type
- Error
(async, static) create() → {Promise.<WirehairEncoder>}
Asynchronously creates and initializes a WirehairEncoder instance.
Ensures the Wirehair WebAssembly module is initialized before creating the encoder.
- Source:
Returns:
A promise that resolves to a new WirehairEncoder instance.
- Type
- Promise.<WirehairEncoder>