CoapPacket

- Documented `getOptionLenType(ubyte)`
- Moved to module-level the two enums `OptionLenType` and `OptionDeltaType`
This commit is contained in:
Tristan B. Velloza Kildaire 2023-09-29 10:12:36 +02:00
parent 3d37dd526f
commit ceec2e20e7
1 changed files with 26 additions and 16 deletions

View File

@ -31,6 +31,24 @@ public struct CoapOption
// TODO: remove this
import std.stdio : writeln;
private enum OptionLenType
{
ZERO_TO_TWELVE,
_8BIT_EXTENDED,
_12_BIT_EXTENDED,
UPPER_PAYLOAD_MARKER
}
private enum OptionDeltaType
{
ZERO_TO_TWELVE,
_8BIT_EXTENDED,
_12_BIT_EXTENDED,
UPPER_PAYLOAD_MARKER
}
/**
* Represents a CoAP packet
*/
@ -663,22 +681,14 @@ public class CoapPacket
return packet;
}
private enum OptionLenType
{
ZERO_TO_TWELVE,
_8BIT_EXTENDED,
_12_BIT_EXTENDED,
UPPER_PAYLOAD_MARKER
}
private enum OptionDeltaType
{
ZERO_TO_TWELVE,
_8BIT_EXTENDED,
_12_BIT_EXTENDED,
UPPER_PAYLOAD_MARKER
}
/**
* Extracts the option length encoding
* type from the header
*
* Params:
* hdr = the header
* Returns: the `OptionLenType`
*/
private static OptionLenType getOptionLenType(ubyte hdr)
{
ubyte type = (hdr&15);