Follow-up to the chain-log WIT boundary cleanup (PR #185, commit 5c68311), which converted assemble_log and project_chain_log into From impls under the "verb-named conversions should be From" idiom.
Problem
Three verb-named converters remain in the bind macro (crates/nexum-sdk/src/wit_bindgen_macro.rs):
convert_err (wit HostError -> sdk HostError)
sdk_err_into_wit (sdk HostError -> wit HostError)
convert_level (tracing Level -> wit logging::Level)
Each is a pure, infallible type-to-type conversion expressed as a named function, so call sites read .map_err(convert_err) instead of ? / .map_err(Into::into).
Proposed
Emit each as a From impl in the macro. This is orphan-rule-allowed because the macro expands in the per-cdylib module crate, where the wit type is local and can sit as the Self (or trait-param) side:
impl From<HostError> for $crate::host::HostError
impl From<$crate::host::HostError> for HostError (its _ => Internal wildcard for the #[non_exhaustive] sdk enum is fine inside From)
impl From<$crate::Level> for nexum::host::logging::Level (body stays the if ladder since tracing_core::Level is a const set, not an enum)
Scope / cost
Ripples to every module lib.rs .map_err(convert_err) / sdk_err_into_wit / convert_level call site, so it is its own focused PR rather than part of the chain-log change. No behaviour change; pure ergonomics/idiom.
Follow-up to the chain-log WIT boundary cleanup (PR #185, commit 5c68311), which converted
assemble_logandproject_chain_logintoFromimpls under the "verb-named conversions should beFrom" idiom.Problem
Three verb-named converters remain in the bind macro (
crates/nexum-sdk/src/wit_bindgen_macro.rs):convert_err(witHostError-> sdkHostError)sdk_err_into_wit(sdkHostError-> witHostError)convert_level(tracingLevel-> witlogging::Level)Each is a pure, infallible type-to-type conversion expressed as a named function, so call sites read
.map_err(convert_err)instead of?/.map_err(Into::into).Proposed
Emit each as a
Fromimpl in the macro. This is orphan-rule-allowed because the macro expands in the per-cdylib module crate, where the wit type is local and can sit as theSelf(or trait-param) side:impl From<HostError> for $crate::host::HostErrorimpl From<$crate::host::HostError> for HostError(its_ => Internalwildcard for the#[non_exhaustive]sdk enum is fine insideFrom)impl From<$crate::Level> for nexum::host::logging::Level(body stays theifladder sincetracing_core::Levelis a const set, not an enum)Scope / cost
Ripples to every module
lib.rs.map_err(convert_err)/sdk_err_into_wit/convert_levelcall site, so it is its own focused PR rather than part of the chain-log change. No behaviour change; pure ergonomics/idiom.