Skip to main content

Crate wecom_transport

Crate wecom_transport 

Source
Expand description

Transport layer for the WeChat Work client — HTTP (reqwest).

§Key types

  • Transport — unified handle holding Arc<dyn TransportBackend>. Accepts any TransportBackend via From<T> or Transport::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§

ContentRange
Parsed Content-Range header value.
Endpoint
Transport-level unified addressing — a type-indexed capability bag.
EndpointCatalog
Centralized override catalog for built-in endpoints.
ExecuteOutput
The complete JSON output of a transport call.
Extensions
Type-indexed bag of arbitrary request-scoped configuration.
GatewayRes
网关响应信封(transport 响应侧默认):直接反序列化 ApiResponse 并做 error.code 校验。
HttpEndpoint
HTTP backend family capability.
HttpRequest
Raw HTTP request builder implementing IntoFuture.
HttpResponse
原始 HTTP 响应。
HttpTransportBackend
HTTP transport — wraps a backend (HttpClient).
MaskedHeaders
A wrapper around reqwest::header::HeaderMap that masks sensitive header values in its Debug output.
PassthroughReq
透传信封:不包装,原样发送业务 JSON(transport 请求侧默认)。
PollEndpoint
Capability describing where TaskQuery long-task polling rounds go.
PollEvent
Event emitted after each polling round during long-task execution.
RequestOptions
Per-request configuration for transport / protocol layers.
Transport
Unified transport handle dispatching to any type implementing TransportBackend via Arc<dyn TransportBackend>.
TransportBuilder
Deferred-error builder for Transport.
TransportRequest
A transport request that bundles a transport backend reference with request data, providing builder methods and IntoFuture.
WireOptions
Pure wire-level per-request configuration.

Enums§

Error
Transport-layer errors — network, HTTP, parse, API, and other failures.
HttpRequestPayload
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§

CatalogKey
Key type of an EndpointCatalog: identifies the built-in endpoints of a domain and provides their built-in defaults.
EndpointExt
A value that can be stored in the Endpoint capability bag.
EndpointHttpExt
Extension methods for reading HTTP-specific fields from an Endpoint bag.
Extension
A value storable in Extensions. Blanket-implemented — no manual impl.
HttpClient
唯一发送抽象:执行一个 HttpRequest,返回原始 HttpResponse
IntoCowEndpoint
Trait for converting various endpoint representations into Cow<'a, Endpoint>.
IntoCowValue
Trait for types that can be converted into Cow<'a, serde_json::Value>.
IntoHeaderName
A name that can be converted into a HeaderName.
IntoHeaderValue
A value that can be converted into a HeaderValue.
IntoRequestPayload
Trait for types that can be converted into an HttpRequestPayload.
RequestEnvelope
请求侧信封:把业务 JSON 包装为服务端期望的请求体。
ResponseEnvelope
响应侧信封:把响应体 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_len chars.

Type Aliases§

ByteStream
异步字节流类型别名,用于流式下载等场景。
PollCallback
Callback type paired with PollEvent.