Skip to main content

Crate asx_rs

Crate asx_rs 

Source
Expand description

§asx-rs — AS2/AS4 EDI protocol library

asx-rs is an async-native, memory-safe Rust library for the AS2 (RFC 4130) and AS4 (OASIS ebMS3 + eDelivery) EDI transport protocols. The crate is published as asx-rs; the library itself is imported as asx_rs.

§Feature flags

The crate uses Cargo feature flags to limit the compiled surface and dependency tree. The default feature set is ["interop-strict", "async-ocsp", "compression", "trace"].

FeatureEnablesRequired by
as2AS2 send/receive free functions (as2::send_sync, as2::receive_sync) and async wrappers (as2::send_async, as2::receive_async)anything using AS2
as4AS4 send/receive free functions (as4::send_sync, as4::receive_push_with_dedup_sync), receipt verification (as4::verify_sync_response), As4PullStore, and protocol configuration (pmode, types)anything using AS4
compressionZlib/GZIP payload compression via flate2AS2/AS4 policy.compress = true (default)
async-ocspAsync OCSP responder fetching via reqwestproduction OCSP validation
interop-strict(default) Strict interop mode as the default. Governs header/ambiguity handling only — not the security policy; see InteropModeAll profiles
interop-relaxedRelaxed mode helpers available alongside strictLegacy partner interop
traceExperimental tracing instrumentation for selected protocol pathsObservability
prometheusBuilt-in Prometheus/OpenMetrics text MetricsSink adapter (observability::PrometheusMetricsSink)Native metrics export
opentelemetryOpenTelemetry MetricsSink adapter (observability::OtelMetricsSink)Native metrics export
dnsBuilt-in BDXL resolver (smp::HickoryBdxlResolver) for Peppol/CEF participant discoverySmlDiscovery::Naptr without a custom BdxlResolver
testingExposes fixtures and matrix test-scaffold modulesIntegration test harness
serverAxum router integration (as2_router, as4_router, As2AxumHandler, As4AxumHandler)HTTP receive
clientAsync HTTP egress transport via reqwest (As2HttpTransport, As4HttpTransport)HTTP send

reqwest dependency note:

  • Enabling async-ocsp pulls reqwest for OCSP HTTP fetches.
  • Enabling client also pulls reqwest for protocol egress transports.
  • Enabling both features reuses the same crate dependency; there is no second HTTP stack.

§Minimal feature combinations

# AS2 only (sign, encrypt, OCSP; compression is enabled by default):
asx-rs = { version = "0.14", features = ["as2", "async-ocsp"] }

# AS4 only (sign, encrypt; compression is enabled by default):
asx-rs = { version = "0.14", features = ["as4", "async-ocsp"] }

# Both protocols with compression:
asx-rs = { version = "0.14", features = ["as2", "as4", "compression", "async-ocsp"] }

# AS4 with Peppol/CEF dynamic discovery:
asx-rs = { version = "0.14", features = ["as4", "client", "dns"] }

# Both protocols, relaxed interop for legacy partners:
asx-rs = { version = "0.14", features = ["as2", "as4", "interop-relaxed", "async-ocsp"] }

Note: as2 and as4 are not in the default feature set. Adding asx-rs without explicit features compiles only the shared infrastructure (core, crypto, reliability, observability).

§Security notes

  • AS2 trust-verifier traits are intentionally open so applications and tests can supply their own verification backends. Prefer local deterministic test verifiers over crate-exported bypass helpers.
  • PKIX chain validation requires at least one trust-anchor PEM in CertHandle::trust_anchor_pems (fail-closed when empty).
  • OCSP freshness checking (thisUpdate/nextUpdate) is enforced automatically when OcspMode is not Disabled.
  • HTTP egress transports are HTTPS-only.

Re-exports§

pub use core::AsxError;
pub use core::CryptoAdmissionControl;
pub use core::ErrorCode;
pub use core::ErrorContext;
pub use core::Result;
pub use credentials::PartnerCredentials;

Modules§

as2
as4
core
credentials
Unified cross-protocol credential container for AS2/AS4 send paths.
crypto
fixtures
Fixture-catalog APIs for testing feature integration harnesses.
http
interop
lifecycle
matrix
Interoperability matrix execution APIs for the testing feature.
observability
presets
Startup validation for regulated deployments.
reliability
sbdh
Standard Business Document Header (SBDH) — UN/CEFACT SBDH 1.3.
smp
PEPPOL / CEF Service Metadata Publisher (SMP) client.
storage
Pluggable storage backends for dedup and reconciliation.
transport
HTTP transport adapters for AS2 and AS4.
wire