Skip to main content

strata_web_api/
lib.rs

1//! Strata Web API: W3C Web Platform APIs in Pure Idiomatic Rust.
2//!
3//! # Examples
4//!
5//! ```rust
6//! use strata_web_api::cookie::CookieJar;
7//!
8//! let mut jar = CookieJar::new();
9//! jar.process_set_cookie("session=xyz; Path=/", "https://example.com/api");
10//! assert_eq!(jar.len(), 1);
11//! ```
12
13pub mod cache;
14pub mod clipboard;
15pub mod cookie;
16pub mod fetch;
17pub mod geolocation;
18pub mod http2;
19pub mod huffman_table;
20pub mod tls;
21pub mod websocket;
22
23pub use cache::{Cache, CacheEntry, CacheStorage};
24pub use clipboard::{Clipboard, ClipboardError};
25pub use cookie::{
26    can_set_cookie_domain, default_path_for_request, domain_matches, parse_http_date, path_matches,
27    Cookie, CookieJar, SameSite,
28};
29pub use fetch::{
30    compute_origin, decode_chunked_body, decompress_body, fetch, fetch_single,
31    is_cors_simple_request, parse_http_response, resolve_redirect_url, AbortController,
32    AbortSignal, FetchError, FormData, Headers, ParsedUrl, RequestCredentials, RequestInit,
33    RequestMode, Response,
34};
35pub use geolocation::{
36    haversine_distance_meters, initial_bearing_degrees, GeoCoordinates, Geolocation,
37    GeolocationError, GeolocationOptions, GeolocationPosition,
38};
39pub use http2::{
40    decode_hpack_headers, encode_hpack_headers, execute_http2_request, Http2Frame, FLAG_ACK,
41    FLAG_END_HEADERS, FLAG_END_STREAM, FRAME_CONTINUATION, FRAME_DATA, FRAME_GOAWAY, FRAME_HEADERS,
42    FRAME_PING, FRAME_PRIORITY, FRAME_PUSH_PROMISE, FRAME_RST_STREAM, FRAME_SETTINGS,
43    FRAME_WINDOW_UPDATE,
44};
45pub use tls::{create_tls_stream, get_or_init_tls_config, HttpTransportStream};
46pub use websocket::{
47    base64_encode, compute_sec_websocket_accept, decode_frame, encode_frame,
48    generate_sec_websocket_key, sha1, WebSocket, WsError, WsFrame, WsMessage, WsOpcode, WsState,
49};
50
51pub mod prelude {
52    pub use super::cache::{Cache, CacheEntry, CacheStorage};
53    pub use super::clipboard::{Clipboard, ClipboardError};
54    pub use super::cookie::{Cookie, CookieJar, SameSite};
55    pub use super::fetch::{
56        fetch, AbortController, AbortSignal, FetchError, FormData, Headers, RequestCredentials,
57        RequestInit, RequestMode, Response,
58    };
59    pub use super::geolocation::{
60        haversine_distance_meters, GeoCoordinates, Geolocation, GeolocationError,
61        GeolocationPosition,
62    };
63    pub use super::websocket::{WebSocket, WsError, WsMessage, WsOpcode, WsState};
64}