Create a BitBlob from binary data, e.g. serialized data
Create a BitBlob from an hexadecimal string representation
Convenience overload
Support for comparison (rvalue overload)
Support for comparison
Used for sha256Of
Convenience overload
Format the hash as a lowercase hex string
Get the string representation of this hash
Convenience enum
Public because of a visibility bug
Support deserialization
The size of the hash, in bytes
Test toString
import std.string : toUpper; alias Hash = BitBlob!32; Hash gen1 = GenesisBlockHashStr; assert(format("%s", gen1) == GenesisBlockHashStr); assert(format("%x", gen1) == GenesisBlockHashStr[2 .. $]); assert(format("%X", gen1) == GenesisBlockHashStr[2 .. $].toUpper()); assert(format("%w", gen1) == GenesisBlockHashStr); assert(gen1.toString() == GenesisBlockHashStr); assert(Hash(gen1.toString()) == gen1); assert(Hash.fromString(gen1.toString()) == gen1);
Make sure toString does not allocate even if it's not @nogc
import core.memory; alias Hash = BitBlob!32; Hash gen1 = GenesisBlockHashStr; char[Hash.StringBufferSize] buffer; auto statsBefore = GC.stats(); formattedWrite(buffer[], "%s", gen1); auto statsAfter = GC.stats(); assert(buffer == GenesisBlockHashStr); assert(statsBefore.usedSize == statsAfter.usedSize);
Test initialization from big endian
import std.algorithm.mutation : reverse; ubyte[32] genesis = GenesisBlockHash; genesis[].reverse; auto h = BitBlob!(32)(genesis, false); assert(h.toString() == GenesisBlockHashStr);
A value type representing a large binary value