Expand description
Metadata normalization for backward compatibility Metadata normalization for symbol attributes
This module provides normalization of legacy metadata keys to canonical forms, enabling backward compatibility while transitioning to standardized metadata keys.
§Design Principles
- User Convenience: Short forms (
async) map to canonical (is_async) for easier queries - No Data Loss: Unknown keys are preserved without modification
- Last-Wins Semantics: If both short and canonical keys exist, canonical wins
- Transparent: Plugins use canonical keys (is_async); normalizer handles user input
§Usage
use sqry_core::normalizer::MetadataNormalizer;
use std::collections::HashMap;
let mut raw_metadata = HashMap::new();
raw_metadata.insert("async".to_string(), "true".to_string()); // Short form
raw_metadata.insert("is_static".to_string(), "true".to_string()); // Canonical form
raw_metadata.insert("custom_key".to_string(), "value".to_string()); // Unknown
let normalizer = MetadataNormalizer::new();
let normalized = normalizer.normalize(raw_metadata);
assert_eq!(normalized.get("is_async"), Some(&"true".to_string())); // Normalized to canonical
assert_eq!(normalized.get("is_static"), Some(&"true".to_string())); // Preserved
assert_eq!(normalized.get("custom_key"), Some(&"value".to_string()));// Preserved§Mapping Strategy
The normalizer uses a static mapping table. User-friendly short forms map TO the
canonical keys defined in sqry_core::metadata::keys:
async→is_async(matches metadata::keys::IS_ASYNC)static→is_static(matches metadata::keys::IS_STATIC)const→is_const(matches metadata::keys::IS_CONST)final→is_final(matches metadata::keys::IS_FINAL)abstract→is_abstract(matches metadata::keys::IS_ABSTRACT)- And more…
Keys already in canonical form (is_async) or not in the mapping table are
preserved as-is.
Structs§
- Metadata
Normalizer - Metadata normalizer for query convenience