Nim OID support. An OID is a global ID that consists of a timestamp, a unique counter and a random value. This combination should suffice to produce a globally distributed unique ID. This implementation was extracted from the Mongodb interface and it thus binary compatible with a Mongo OID.
This implementation calls math.randomize()
for the first call of genOid
.
Oid = object time: int32 fuzz: int32 count: int32
proc `==`(oid1: Oid; oid2: Oid): bool {...}{.raises: [], tags: [].}
proc hexbyte(hex: char): int {...}{.raises: [], tags: [].}
proc parseOid(str: cstring): Oid {...}{.raises: [], tags: [].}
proc oidToString(oid: Oid; str: cstring) {...}{.raises: [], tags: [].}
proc `$`(oid: Oid): string {...}{.raises: [], tags: [].}
proc genOid(): Oid {...}{.raises: [], tags: [].}
proc generatedTime(oid: Oid): Time {...}{.raises: [], tags: [].}
© 2006–2018 Andreas Rumpf
Licensed under the MIT License.
https://nim-lang.org/docs/oids.html