Skip to main content

lino_rest_api/
lib.rs

1//! A REST API framework and client that speak Links Notation instead of JSON.
2//!
3//! Everything the HTTP standards expect of a REST service — content negotiation,
4//! conditional requests, problem details, collection pagination, automatic
5//! `HEAD`/`OPTIONS`/`405`, CORS, a service description and an OpenAPI document —
6//! is provided out of the box, with LINO as the default wire format and JSON as
7//! a fallback. The wire protocol is defined in `docs/spec/README.md`, and the
8//! JavaScript, Python and Rust packages speak it byte for byte alike, so the
9//! three implementations produce the same entity tags.
10
11// Every fallible operation in this crate reports a `LinoHttpError`, because that
12// is what becomes a problem details response. It is larger than clippy's
13// threshold for an error type, and boxing it at every call site would cost more
14// in noise than it saves in moved bytes.
15#![allow(clippy::result_large_err)]
16
17pub mod app;
18pub mod client;
19pub mod codec;
20pub mod collection;
21pub mod cors;
22pub mod description;
23pub mod etag;
24pub mod headers;
25pub mod media_type;
26pub mod middleware;
27pub mod problem;
28pub mod query;
29pub mod request;
30pub mod resource;
31pub mod response;
32pub mod router;
33pub mod serve;
34pub mod store;
35pub mod value;
36
37// The surface the JavaScript and Python packages export, re-exported at the
38// crate root so that the three libraries are used the same way. Everything
39// remains available through its module for code that prefers the longer path.
40pub use app::{DESCRIPTION_PATH, LinoApp, OPENAPI_PATH, RawRequest, create_lino_app};
41pub use client::{LinoClient, LinoClientError, LinoResponse, RequestOptions, create_lino_client};
42pub use codec::{
43    decode, decode_from, decode_single_line, encode, encode_compact_notation, encode_for,
44    encode_single_line,
45};
46pub use cors::CorsPolicy;
47pub use description::ServiceInfo;
48pub use media_type::{
49    JSON_CONTENT_TYPE, LINO_COMPACT_CONTENT_TYPE, LINO_CONTENT_TYPE, LINO_LINE_CONTENT_TYPE,
50};
51pub use middleware::ResponseParts;
52pub use problem::LinoHttpError;
53pub use request::LinoRequest;
54pub use resource::ResourceOptions;
55pub use response::{LinoResult, accepted, created, no_content, ok, raw_response, status};
56pub use serve::{BoundServer, serve};
57pub use store::{MemoryStore, Store};
58pub use value::{array, boolean, int, object, string};