Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion json2xml/backend_selector.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions lat.md/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Loading