Creates positive 64-bit identifiers for new objects or repeatable external imports. More...
Static Public Member Functions | |
| static long | New () |
| Creates a positive, process-unique identifier for a new deck, note type, note, or card. | |
| static long | FromStableValue (string scope, string value) |
| Derives a deterministic positive identifier from a caller-controlled namespace and stable value. | |
Creates positive 64-bit identifiers for new objects or repeatable external imports.
Decks, note types, notes, and cards occupy a shared validation namespace in an AnkiIO object graph. Use New for fresh objects and FromStableValue when the same external record must receive the same ID on every run. Neither method reserves IDs in another process, examines caller-supplied IDs, or queries an installed Anki profile; always validate the complete graph before output.
|
inlinestatic |
Derives a deterministic positive identifier from a caller-controlled namespace and stable value.
| scope | A non-empty namespace, such as "external-note", separating unrelated identity domains. |
| value | A non-empty stable source identifier whose exact ordinal text is significant. |
The UTF-8 encoding of scope , a null separator, and value is hashed with SHA-256. The low eight hash bytes are interpreted consistently as little-endian, with the sign bit cleared. Equal ordinal inputs—including case and whitespace—always produce equal IDs across supported platforms.
Use different scopes for different object kinds (for example deck, note, and card) so equal source keys do not collide across the shared graph namespace. The 63-bit projection has a small but non-zero collision probability; validation is still required, especially for adversarial or very large imports. This method maps identity only—it does not create a stable Anki note GUID; pass that separately to AnkiNote.
| ArgumentNullException | scope or value is null. |
| ArgumentException | scope or value is empty or whitespace. |
|
inlinestatic |
Creates a positive, process-unique identifier for a new deck, note type, note, or card.
The method is thread-safe and combines a millisecond timestamp-shaped starting point with an atomic counter. Its guarantee is process-local: another process, an explicit imported ID, or an existing Anki collection could use the same number. It is also deliberately not repeatable across runs. Use FromStableValue for deterministic imports and let AnkiValidator detect collisions within the graph being written.