diff --git a/json2xml/backend_selector.py b/json2xml/backend_selector.py index 7e3cb98..59bffc1 100644 --- a/json2xml/backend_selector.py +++ b/json2xml/backend_selector.py @@ -24,7 +24,9 @@ class ConversionRequest: class BackendAdapter(Protocol): """Small adapter seam for conversion backends.""" - name: str + @property + def name(self) -> str: + raise NotImplementedError # pragma: no cover def can_handle(self, request: ConversionRequest) -> bool: raise NotImplementedError # pragma: no cover diff --git a/lat.md/architecture.md b/lat.md/architecture.md index 706f64e..6771bd7 100644 --- a/lat.md/architecture.md +++ b/lat.md/architecture.md @@ -24,6 +24,8 @@ The fast-path module prefers the Rust extension when it can preserve Python sema [[json2xml/dicttoxml_fast.py#dicttoxml]] now normalizes each call into a shared conversion request and asks a tiny backend selector seam to choose Rust or Python. The Rust adapter accepts only requests whose semantics it can preserve, namely no `ids`, custom `item_func`, XML namespaces, XPath mode, root scalar payloads, or special `@` keys. +The backend adapter protocol exposes its diagnostic name as a read-only property, matching the frozen adapter implementations while still allowing selector code to inspect backend metadata. + A local stub for the optional `json2xml_rs` module keeps static analysis aligned with that fallback design, so type checking still passes when the extension is not installed. This keeps fast installs fast without letting the optimized path silently change behavior. The Rust backend writes serializer output into Python's bytes writer instead of building a Rust string and copying it across the extension boundary. This keeps the fast path's peak output memory closer to the final `bytes` object.