Module wire_conv

Module wire_conv 

Source
Expand description

Conversions between wire types (manta-shared) and backend types (manta-backend-dispatcher).

§Why this module exists

Manta uses two error types (see CLAUDE.md’s two-tier error rule):

  • manta_shared::common::error::MantaError — produced by shared helpers (config loader, audit, JWT, kafka).
  • manta_backend_dispatcher::error::Error — used everywhere in the server’s service / backend_dispatcher layers.

Service-layer code calls into manta-shared helpers but needs to produce BackendError results. Rust’s orphan rule blocks the obvious impl From<MantaError> for BackendError because both types are foreign to this crate, so this module exposes a free function instead: callers write .map_err(wire_conv::to_backend)?.

Lives server-side rather than in manta-shared because manta-shared has no knowledge of the backend dispatcher crate.

§Scope

Only error-type mapping is needed at runtime. A NodeDetails converter isn’t required: the only place the two NodeDetails types meet is the HTTP wire, and the JSON serialisation is identical between csm_rs::node::types::NodeDetails and manta_shared::types::dto::NodeDetails.

Functions§

to_backend
Map a MantaError (returned by manta-shared’s pure helpers) onto the structured BackendError that the server’s service layer uses.