ByteStream stream = cast(ubyte[])[0x01, 0x05, 0x16, 0x09, 0x2C, 0xFF, 0x08]; assert(stream.peek!uint () == 0x01_05_16_09); stream.append!(ushort[])([0x4A_2B, 0x59_12]); assert(stream.read!ulong () == 0x01_05_16_09_2C_FF_08_4AUL); assert(stream == [0x2B, 0x59, 0x12]); stream.write!ubyte (0x44, 1); assert(stream == [0x2B, 0x44, 0x12]); stream.write!(ubyte[])([0x01, 0x02, 0x03], 0); assert(stream == [0x01, 0x02, 0x03]);
ByteStream stream = (cast(ubyte[]) "abc\0") ~cast(ubyte[])[0x44]; assert(stream.readTo!string(cast(ubyte) '\0') == "abc"); assert(stream == [0x44]);
ByteStream stream = (cast(ubyte[]) "abc\0") ~cast(ubyte[])[0x44]; assert(stream.readToIncluding!string(cast(ubyte) '\0') == "abc\0"); assert(stream == [0x44]);