Skip to main content

http_type/cookie/
struct.rs

1use super::*;
2
3/// Builder for constructing HTTP cookies.
4///
5/// Provides methods to set various cookie attributes like expiration,
6/// domain, path, and security flags before building the final cookie string.
7#[derive(Clone, Data, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
8pub struct CookieBuilder {
9    /// Cookie name identifier.
10    #[set(type(AsRef<str>))]
11    pub name: CookieKey,
12    /// Cookie value content.
13    #[set(type(AsRef<str>))]
14    pub value: CookieValue,
15    /// Optional expiration date/time string.
16    #[set(skip)]
17    pub expires: Option<String>,
18    /// Optional maximum age in seconds.
19    #[get(type(copy))]
20    #[set(skip)]
21    pub max_age: Option<i64>,
22    /// Optional domain scope for the cookie.
23    #[set(skip)]
24    pub domain: Option<String>,
25    /// Optional path scope for the cookie.
26    #[set(skip)]
27    pub path: Option<String>,
28    /// Optional flag indicating secure (HTTPS-only) transmission.
29    #[get(type(copy))]
30    #[set(skip)]
31    pub secure: Option<bool>,
32    /// Optional flag preventing JavaScript access.
33    #[get(type(copy))]
34    #[set(skip)]
35    pub http_only: Option<bool>,
36    /// Optional SameSite policy setting.
37    #[set(skip)]
38    pub same_site: Option<String>,
39}
40
41/// Parser for HTTP Cookie headers.
42///
43/// Provides functionality to parse Cookie header strings into key-value pairs.
44#[derive(Clone, Copy, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
45pub struct Cookie;