Skip to main content

Crate use_cookie

Crate use_cookie 

Source
Expand description

Small cookie utilities for RustUse.

§Experimental

use-cookie is experimental while the use-web workspace remains below 0.3.0. Expect small API adjustments during the first release wave.

§Example

use use_cookie::{get_cookie, parse_set_cookie_basic};

assert_eq!(get_cookie("session=abc; theme=dark", "theme").as_deref(), Some("dark"));
assert!(parse_set_cookie_basic("session=abc; Path=/; HttpOnly").is_some());

§Scope

  • Cookie header parsing and formatting.
  • Lightweight Set-Cookie inspection for common attributes.
  • Small validation helpers for cookie names.

§Non-goals

  • Browser cookie jars.
  • Public suffix handling.
  • Security policy engines.
  • Session management.

§License

Licensed under either of the following, at your option:

  • Apache License, Version 2.0
  • MIT license

Structs§

Cookie
A cookie name-value pair from the Cookie header.
SetCookie
A lightweight view of a Set-Cookie header.

Functions§

build_cookie_header
Builds a Cookie header string from cookie pairs.
cookie_name_is_valid
Returns true when the cookie name uses a conservative HTTP token character set.
get_cookie
Returns the first cookie value with the requested name.
has_cookie
Returns true when the header contains the requested cookie.
parse_cookie_header
Parses a Cookie header into cookie pairs.
parse_set_cookie_basic
Parses a lightweight Set-Cookie header.