Skip to main content

Crate wip_http

Crate wip_http 

Source
Expand description

Framework-independent standard WIP over HTTP v1 binding.

This crate owns endpoint and route derivation, UTF-8 JSON encoding, canonical success and error response handling, HTTP status mapping, descriptor-guided operation-value conversion. It deliberately performs no I/O and depends on no server framework, TLS implementation, filesystem projection, client cache, or presentation layer. URL schemes, TLS, certificates, authentication mechanisms, proxies, and caches are selected by the HTTP implementation and deployment rather than by WIP conformance.

Logical values remain owned by wip_protocol. Validators and Bytes are encoded in JSON bodies using canonical RFC 4648 Section 4 base64; this crate does not infer WIP validator semantics from ETag or If-Match.

Interface references use exact JSON objects with required scope and name strings in every position. Legacy strings and display shorthand are rejected. Scope is a canonical absolute Worldspace path, not an HTTP endpoint prefix. Optional scope_ref metadata on fetch responses and call interface targets is an opaque string, never base64; absent fields are omitted and null is rejected. Call metadata validates reference shape without resolving scope ancestry or identity, which remain Host checks with InterfaceMismatch precedence.

use wip_http::{Endpoint, Limits, encode_observe_request};
use wip_protocol::ObserveRequest;

let endpoint = Endpoint::parse("http://example.test/api/wip")?;
let limits = Limits::new(64 * 1024, 1024 * 1024, 64)?;
let request = encode_observe_request(
    &endpoint,
    &ObserveRequest { path: "/items/123".into(), depth: 0 },
    limits,
)?;
assert_eq!(request.uri(), "http://example.test/api/wip/v1/observe");
assert_eq!(request.method(), http::Method::POST);

Re-exports§

pub use http;
pub use url;
pub use wip_protocol;

Structs§

CallOperationMetadata
Descriptor-independent fields needed to resolve a call_operation request.
Endpoint
A canonical absolute hierarchical base URL whose path always ends in /.
Limits
Caller-selected hard limits applied before or while decoding JSON.
StatusMismatch
Diagnostic evidence that HTTP metadata disagrees with a valid error envelope.
TransportBindingFailure
A non-success HTTP response that is not a valid WIP protocol failure.

Enums§

BodyKind
Whether a body is being decoded as a request or response.
ClientResponseError
A local failure while classifying or validating a peer response.
CodecError
A malformed or locally disallowed wire representation.
DecodedResponse
A successfully classified client response.
EncodeHttpError
Failure while building an outbound framework-neutral HTTP message.
EndpointError
Why an endpoint is not a valid standard WIP over HTTP base.
InvalidResponseKind
Why a response violates the WIP v1 response contract.
LimitConfigurationError
Why a Limits configuration is not bounded.
RequestMetadataError
A failure while validating inbound HTTP request metadata.
Route
A fixed standard WIP over HTTP v1 route.
TransportFailureKind
Class of non-protocol HTTP failure returned without a valid WIP envelope.

Constants§

JSON_CONTENT_TYPE
The media type emitted for every WIP request and every response with a body.

Functions§

decode_call_operation_metadata
Decodes descriptor-independent call_operation routing metadata.
decode_call_operation_request
Decodes a descriptor-bound call_operation request body.
decode_call_operation_response
Decodes and classifies a descriptor-bound call_operation client response.
decode_fetch_interface_request
Decodes a fetch_interface request body.
decode_fetch_interface_response
Decodes and classifies a fetch_interface client response.
decode_observe_request
Decodes an observe request body.
decode_observe_response
Decodes and classifies an observe client response.
encode_call_operation_request
Encodes a descriptor-bound call_operation HTTP request.
encode_call_operation_response
Encodes a successful call_operation response as a direct body with HTTP 200.
encode_fetch_interface_request
Encodes a fetch_interface HTTP request.
encode_fetch_interface_response
Encodes a successful fetch_interface response as a direct body with HTTP 200.
encode_observe_request
Encodes an observe HTTP request.
encode_observe_response
Encodes a successful observe response as a direct body with HTTP 200.
encode_protocol_error_response
Encodes a canonical Host error envelope using its standard HTTP status.
error_code_name
Returns the stable snake-case wire spelling of a protocol code.
is_json_content_type
Returns whether a Content-Type value denotes UTF-8 application/json.
status_for_error
Returns the canonical HTTP status for a wire-level protocol error.
validate_http_request
Validates mandatory HTTP metadata for an inbound WIP request.