fromHexStringAsRange

Converts a hex text string to a range of bytes.

The input to this function MUST be valid. std.digest.isHexString can be used to check for this if needed.

@safe pure nothrow @nogc
fromHexStringAsRange
(
String
)
(
String hex
)
if ()

Parameters

hex String

String representation of a hexdecimal-encoded byte array.

Return Value

Type: auto

A forward range of bytes.

Examples

import std.range.primitives : ElementType, isForwardRange;
import std.traits : ReturnType;

// The decoder implements a forward range.
static assert(isForwardRange!(ReturnType!(fromHexStringAsRange!string)));
static assert(isForwardRange!(ReturnType!(fromHexStringAsRange!wstring)));
static assert(isForwardRange!(ReturnType!(fromHexStringAsRange!dstring)));

// The element type of the range is always `ubyte`.
static assert(
    is(ElementType!(ReturnType!(fromHexStringAsRange!string)) == ubyte)
);
static assert(
    is(ElementType!(ReturnType!(fromHexStringAsRange!wstring)) == ubyte)
);
static assert(
    is(ElementType!(ReturnType!(fromHexStringAsRange!dstring)) == ubyte)
);

Meta