cookie_monster/lib.rs
1//! An HTTP Cookie crate.
2//!
3//! # Overview
4//! Exposes types like [`Cookie`] and [`CookieJar`] for working with HTTP cookies. This crate
5//! focuses on server side applications. The main goals are simplicity and ease of use.
6//!
7//! # Usage
8//! Add cookie-monster in your Cargo.toml:
9//! ```toml
10//![dependencies]
11//!cookie-monster = "0.1"
12//!```
13//!
14//! # Features
15//! * `jiff`
16//!
17//! Adds support for the [jiff](https://docs.rs/jiff/latest/jiff/) crate.
18//! This exposes methods to [`Cookie`] to retreive the `Expires` and `Max-Age` attributes with jiff
19//! specific types.
20//!
21//! * `chrono`
22//!
23//! Adds support for the [chrono](https://docs.rs/chrono/latest/chrono/) crate.
24//! This exposes methods to [`Cookie`] to retreive the `Expires` and `Max-Age` attributes with
25//! chrono specific types.
26//!
27//! * `time`
28//!
29//! Adds support for the [time](https://docs.rs/time/latest/time/index.html) crate.
30//! This exposes methods to [`Cookie`] to retreive the `Expires` and `Max-Age` attributes with time
31//! specific types.
32//!
33//! * `percent-encode`
34//!
35//! Parse/serialize [`Cookie`]s that are percent-encoded.
36//!
37//! * `axum`
38//!
39//! Adds integration with the [axum](https://docs.rs/axum/latest/axum/) crate.
40//! Implements [`FromRequestParts`](https://docs.rs/axum/latest/axum/extract/trait.FromRequestParts.html),
41//! [`IntoResponse`](https://docs.rs/axum/latest/axum/response/trait.IntoResponse.html) and
42//! [`IntoResponseParts`](https://docs.rs/axum/latest/axum/response/trait.IntoResponseParts.html),
43
44//!
45//! * `http`
46//!
47//! Adds integration with the [http](https://docs.rs/http/latest/http/) crate.
48//! Create a [`CookieJar`] from a [`HeaderMap`](https://docs.rs/http/latest/http/header/struct.HeaderMap.html).
49//! Write a [`CookieJar`] to a [`HeaderMap`](https://docs.rs/http/latest/http/header/struct.HeaderMap.html).
50//!
51//!
52//! ### Honorable mention
53//! This crate takes a lot of inspiration from the [cookie](https://crates.io/crates/cookie) crate.
54
55mod cookie;
56mod error;
57mod jar;
58mod util;
59
60#[cfg(feature = "axum")]
61mod axum;
62
63#[cfg(feature = "http")]
64mod http;
65
66pub use cookie::{Cookie, CookieBuilder, expires::Expires, same_site::SameSite};
67pub use error::Error;
68pub(crate) type Result<T, E = Error> = ::std::result::Result<T, E>;
69pub use jar::CookieJar;