Expand description
Task-local “current” TypeSchemaRegistry handle.
This module exposes an ambient registry that is pushed by Runtime’s
execution entry points and consumed by free functions that previously
reached for the process-global STDLIB_SCHEMA_REGISTRY / NEXT_SCHEMA_ID
statics. The scoping is three-layered to cover both async and synchronous
entry points, with a process-wide default as the final fallback:
- Task-local (
CURRENT_SCHEMA_REGISTRY) — survives task migration across tokio worker threads, so any descendant.awaitin a Shape execution future inherits the registry automatically. - Thread-local (
SYNC_CURRENT_SCHEMA_REGISTRY) — fallback for synchronous entry points (CLI, tests, REPL one-shots) that are not running under a tokio task. ASyncRegistryScopeRAII guard pushes/pops the value so nested Runtimes on one thread compose correctly. - Process-wide default (
DEFAULT_SCHEMA_REGISTRY) — a single stdlib-populated registry shared by scopeless callers. Preserves the pre-B1.7 semantic that every caller sees some registry: ad-hoc tooling, static initialisers, and unit tests that don’t install a scope all share this handle instead of being forced to panic or observeNone.
Mirrors the B5 shape_value::shape_graph_current::DEFAULT_SHAPE_TABLE
pattern that retired the legacy GLOBAL_SHAPE_TABLE static.
Lookup order: task-local → thread-local → process default. Both
current_registry and try_current_registry always return a
usable handle; callers never need to branch on None or on a panic
any more. Scoped callers (installed by Runtime) still get per-VM
isolation, which was the original B1 goal.
Structs§
- Sync
Registry Scope - RAII guard that installs a registry on the thread-local slot for the lifetime of the guard.
Functions§
- current_
registry - Return a handle to the current ambient
TypeSchemaRegistry. - default_
registry - Return the process-wide default schema-registry handle.
- try_
current_ registry - Alias for
current_registryreturningOptionfor historical API compatibility. - with_
async_ scope - Run
futwithregistryinstalled as the task-local current registry.