wip_http/lib.rs
1//! Framework-independent standard WIP over HTTP v1 binding.
2//!
3//! This crate owns endpoint and route derivation, UTF-8 JSON encoding, canonical
4//! success and error response handling, HTTP status mapping, descriptor-guided
5//! operation-value conversion. It deliberately performs no I/O and depends on no
6//! server framework, TLS implementation, filesystem projection, client cache, or
7//! presentation layer. URL schemes, TLS, certificates, authentication mechanisms,
8//! proxies, and caches are selected by the HTTP implementation and deployment
9//! rather than by WIP conformance.
10//!
11//! Logical values remain owned by [`wip_protocol`]. Validators and `Bytes` are
12//! encoded in JSON bodies using canonical RFC 4648 Section 4 base64; this crate
13//! does not infer WIP validator semantics from `ETag` or `If-Match`.
14//!
15//! ```
16//! use wip_http::{Endpoint, Limits, encode_observe_request};
17//! use wip_protocol::ObserveRequest;
18//!
19//! let endpoint = Endpoint::parse("http://example.test/api/wip")?;
20//! let limits = Limits::new(64 * 1024, 1024 * 1024, 64)?;
21//! let request = encode_observe_request(
22//! &endpoint,
23//! &ObserveRequest { path: "/items/123".into(), depth: 0 },
24//! limits,
25//! )?;
26//! assert_eq!(request.uri(), "http://example.test/api/wip/v1/observe");
27//! assert_eq!(request.method(), http::Method::POST);
28//! # Ok::<(), Box<dyn std::error::Error>>(())
29//! ```
30
31#![deny(missing_docs)]
32
33mod codec;
34mod endpoint;
35mod error;
36mod json;
37mod response;
38
39pub use codec::{
40 CallOperationMetadata, EncodeHttpError, RequestMetadataError, decode_call_operation_metadata,
41 decode_call_operation_request, decode_call_operation_response, decode_fetch_interface_request,
42 decode_fetch_interface_response, decode_observe_request, decode_observe_response,
43 encode_call_operation_request, encode_call_operation_response, encode_fetch_interface_request,
44 encode_fetch_interface_response, encode_observe_request, encode_observe_response,
45 encode_protocol_error_response, is_json_content_type, validate_http_request,
46};
47pub use endpoint::{Endpoint, EndpointError, JSON_CONTENT_TYPE, Route};
48pub use error::{BodyKind, CodecError, LimitConfigurationError, Limits};
49pub use response::{
50 ClientResponseError, DecodedResponse, InvalidResponseKind, StatusMismatch,
51 TransportBindingFailure, TransportFailureKind, error_code_name, status_for_error,
52};
53
54/// Framework-neutral HTTP types used by this binding's public API.
55pub use http;
56/// URL type used by [`Endpoint`].
57pub use url;
58/// Transport-independent logical protocol model used by this binding.
59pub use wip_protocol;