module history.model; import std.datetime.systime; /** * A history containing a series of items, which all usually pertain to a * certain target entity. */ struct History { immutable ulong id; } /** * The type of history item. This can be used as a discriminator value to treat * different history types separately. */ enum HistoryItemType : string { TEXT = "TEXT" } HistoryItemType getHistoryItemType(string text) { import std.traits; static foreach (t; EnumMembers!HistoryItemType) { if (text == t) return t; } throw new Exception("Unknown history item type: " ~ text); } /** * A single item in a history. It has a UTC timestamp and a type. From the type, * one can get more specific information. */ struct HistoryItem { immutable ulong id; immutable ulong historyId; immutable SysTime timestamp; immutable HistoryItemType type; } /** * Additional data for history items with the TEXT type. */ struct HistoryItemText { immutable ulong itemId; immutable string content; }