Expand description
Transport layer for the WeChat Work client — HTTP (reqwest).
§Key types
Transport— unified handle holdingArc<dyn TransportBackend>. Accepts anyTransportBackendviaFrom<T>orTransport::new().TransportBackend— open trait for custom transport backends.Endpoint— unified addressing carrying HTTP info for one call.TransportRequest— builder-style request handle,IntoFuture-driven.
§Implementing a custom backend
Building blocks for custom TransportBackend
implementations (protocol types, long-task polling, resumable download,
request envelope) live under backend — kept out of the crate root so
the top level stays focused on the consumer API.
§Minimal example
ⓘ
let backend = wecom_transport::HttpTransportBackend::default();
let transport = wecom_transport::Transport::from(backend)
.with_header("Authorization", "Bearer x")?;
let endpoint = Endpoint::new("https://api.example.com", "/cgi-bin/action");
let result = transport.invoke(&endpoint, &serde_json::json!({})).await?;Re-exports§
pub use traits::TransportBackend;pub use traits::TransportResponse;
Modules§
- backend
- Building blocks for implementing custom
TransportBackends. - telemetry
- Outbound request observability helpers.
- traits
- Transport trait definitions — open extension points.
Macros§
- impl_
request_ builder - Inject a uniform builder surface into a request type.
Structs§
- Content
Range - Parsed
Content-Rangeheader value. - Endpoint
- Transport-level unified addressing — a type-indexed capability bag.
- Endpoint
Catalog - Centralized override catalog for built-in endpoints.
- Execute
Output - The complete JSON output of a transport call.
- Extensions
- Type-indexed bag of arbitrary request-scoped configuration.
- Gateway
Res - 网关响应信封(transport 响应侧默认):直接反序列化
ApiResponse并做error.code校验。 - Http
Endpoint - HTTP backend family capability.
- Http
Request - Raw HTTP request builder implementing
IntoFuture. - Http
Response - 原始 HTTP 响应。
- Http
Transport Backend - HTTP transport — wraps a backend (
HttpClient). - Masked
Headers - A wrapper around
reqwest::header::HeaderMapthat masks sensitive header values in itsDebugoutput. - Passthrough
Req - 透传信封:不包装,原样发送业务 JSON(transport 请求侧默认)。
- Poll
Endpoint - Capability describing where
TaskQuerylong-task polling rounds go. - Poll
Event - Event emitted after each polling round during long-task execution.
- Request
Options - Per-request configuration for transport / protocol layers.
- Transport
- Unified transport handle dispatching to any type implementing
TransportBackendviaArc<dyn TransportBackend>. - Transport
Builder - Deferred-error builder for
Transport. - Transport
Request - A transport request that bundles a transport backend reference with
request data, providing builder methods and
IntoFuture. - Wire
Options - Pure wire-level per-request configuration.
Enums§
- Error
- Transport-layer errors — network, HTTP, parse, API, and other failures.
- Http
Request Payload - HTTP 请求 payload 类型。
Constants§
- E_
CONFIG_ TRANSPORT - Transport configuration error code.
- E_HTTP
- HTTP error code (non-2xx status).
- E_
NETWORK - Network-level error code (DNS, TLS, timeout, connection refused).
- E_OTHER
- Catch-all error code for transport-layer failures.
- E_PARSE
- Parse error code (deserialization failure).
Traits§
- Catalog
Key - Key type of an
EndpointCatalog: identifies the built-in endpoints of a domain and provides their built-in defaults. - Endpoint
Ext - A value that can be stored in the
Endpointcapability bag. - Endpoint
Http Ext - Extension methods for reading HTTP-specific fields from an
Endpointbag. - Extension
- A value storable in
Extensions. Blanket-implemented — no manual impl. - Http
Client - 唯一发送抽象:执行一个
HttpRequest,返回原始HttpResponse。 - Into
CowEndpoint - Trait for converting various endpoint representations into
Cow<'a, Endpoint>. - Into
CowValue - Trait for types that can be converted into
Cow<'a, serde_json::Value>. - Into
Header Name - A name that can be converted into a
HeaderName. - Into
Header Value - A value that can be converted into a
HeaderValue. - Into
Request Payload - Trait for types that can be converted into an
HttpRequestPayload. - Request
Envelope - 请求侧信封:把业务 JSON 包装为服务端期望的请求体。
- Response
Envelope - 响应侧信封:把响应体 JSON 解析为归一化的
ApiResponse。
Functions§
- fmt_opt
- Format an
Option<T: Display>:Some(v)→"v",None→"?". - trunc_
display - Truncate a string for Display: first line only, max
max_lenchars.
Type Aliases§
- Byte
Stream - 异步字节流类型别名,用于流式下载等场景。
- Poll
Callback - Callback type paired with
PollEvent.