http-query 0.2.0

A client and server SDK for the HTTP QUERY method (RFC 10008).
Documentation
//! `http-query` is a client and server SDK for the **HTTP `QUERY` method**
//! ([RFC 10008]).
//!
//! `QUERY` is a safe, idempotent request method that carries a request body
//! describing a query to be evaluated against the target resource. Unlike GET,
//! the query travels in the body rather than the URI; unlike POST, the request
//! is safe and may be retried and cached.
//!
//! # Sending a query (requires the `client` feature, enabled by default)
//!
//! ```no_run
//! # async fn run() -> Result<(), http_query::Error> {
//! use http_query::Client;
//!
//! let client = Client::new();
//! let resp = client
//!     .query_string("https://example.org/search", "application/sql", "SELECT 1")
//!     .await?;
//! println!("status: {}", resp.status());
//! # Ok(()) }
//! ```
//!
//! # Discovering support
//!
//! [`Client::options`] issues an `OPTIONS` request and reports QUERY support
//! from the `Allow` and `Accept-Query` header fields. `Accept-Query` is parsed
//! as an [RFC 9651] Structured Fields list.
//!
//! # Result vs. equivalent resource
//!
//! A response may advertise two distinct URIs (RFC 10008 §2.3–2.4):
//! `Content-Location` (the stored result, [`Client::fetch_result`]) and
//! `Location` (the equivalent resource whose GET re-runs the query,
//! [`Client::fetch_equivalent`]).
//!
//! # Serving QUERY
//!
//! The [`server`] module provides framework-agnostic helpers to validate an
//! incoming QUERY request and advertise support. See `examples/axum_server.rs`.
//!
//! [RFC 10008]: https://www.rfc-editor.org/rfc/rfc10008.html
//! [RFC 9651]: https://www.rfc-editor.org/rfc/rfc9651.html

#![forbid(unsafe_code)]
#![warn(missing_docs)]

mod accept_query;
mod cache;
mod consts;
mod error;
mod response;

pub mod server;

#[cfg(feature = "client")]
mod client;

pub use accept_query::{format_accept_query, matches_media_range, parse_accept_query};
pub use cache::cache_key;
pub use consts::{
    query_method, DEFAULT_MAX_REDIRECTS, HEADER_ACCEPT, HEADER_ACCEPT_QUERY, HEADER_ALLOW,
    HEADER_CONTENT_LOCATION, HEADER_CONTENT_TYPE, HEADER_LOCATION, MEDIA_TYPE_FORM,
    MEDIA_TYPE_JSON, METHOD_QUERY,
};
pub use error::{Error, Result};
pub use response::{supports_query, Discovery, ResponseInfo};

#[cfg(feature = "client")]
pub use client::{check_status, Client};