Expand description
The IfcGloballyUniqueId (22-char GlobalId) home: alphabet, validators, the leading-GlobalId reader and the two deterministic minters.
Two notions on purpose, NOT interchangeable (#7777): is_global_id_shaped
(length + alphabet) decides whether a token is RECOGNISED as a GlobalId, so
the merge sees every collision real files produce (some exporters write a
first character outside 0..=3); is_valid_global_id additionally
enforces the 128-bit packing rule and gates what we WRITE or trust
(appearance). Strictness must never decide whether a collision is seen.
Constants§
- ALPHABET
- buildingSMART base64 alphabet (64 chars) used by IfcGloballyUniqueId.
Functions§
- decode_
bits - The 128 bits a GlobalId encodes: the inverse of
encode, orNonewhensis notis_valid_global_id(a first character past'3'would need a 129th bit). A GlobalId is a compressed GUID, so these bits are the GUID a tool that expands GlobalIds (IfcOpenShell’sguid.expand) prints. - deterministic
- Deterministic 22-char GlobalId from an arbitrary seed. A faithful port of
@ifc-lite/parser’sdeterministicGlobalId(four independent 32-bit rolling hashes cross-mixed into a 128-bit state, stamped MSB-first as2 + 21*6bits), pinned byrust/export/tests/fixtures/deterministic_global_id_vectors.json. - encode
- Encode 128 bits as an IfcGloballyUniqueId: 22 characters of
ALPHABET, read MSB-first. 22 x 6 = 132 bits is four more than a GUID holds, so the FIRST character carries only the top 2 bits (0..3) and each of the other 21 carries 6. That split is the IFC convention, not RFC 4648 base64: a different alphabet order, no padding, and no byte alignment. - hash128
- The 128-bit state
deterministicencodes, exposed so a caller that needs the bits (to derive further ids from them) gets the same hash rather than a second one. - is_
global_ id_ shaped - True for a 22-char token drawn entirely from
ALPHABET(^[0-9A-Za-z_$]{22}$). Does not check the first-character range. - is_
valid_ global_ id is_global_id_shapedplus the spec rule that the first character carries only 2 bits ('0'..='3'), since 22 chars hold2 + 21 * 6 = 128bits.- leading_
global_ id - The first
'...'string of a STEP entity line, when it is GlobalId-shaped. Only the first 128 bytes are inspected. Rootedness (whether the entity type has a GlobalId at all) is the caller’s decision. - placeholder
- Deterministic 22-char GlobalId-shaped placeholder derived from an express id
(right-aligned base-64 of
id + 0x1000_0000, zero-padded). Intentionally NOT the TypeScript mint: schema conversion pins this divergence (schema_convert_tests.rs). - read_
leading_ global_ id - Rendered-line reader used by the merge’s collision bookkeeping: the first
'...'after the first(, anywhere in the text (no window), when it is GlobalId-SHAPED. Deliberately the lenientis_global_id_shapedtest, notis_valid_global_id: whether a collision is SEEN must never depend on validity, or two entities sharing a non-conforming id are silently kept. - replace_
rendered_ global_ id textwith the string read byread_leading_global_id’s scan replaced bynew_guid; unchanged when the line has no quoted first attribute.