pub struct CallCookies { /* private fields */ }Expand description
Represents HTTP cookies for an API call.
This struct manages HTTP cookies using the same ParamValue pattern as query, path, and header parameters, allowing for type-safe cookie handling with automatic OpenAPI schema generation.
§Examples
use clawspec_core::CallCookies;
let cookies = CallCookies::new()
.add_cookie("session_id", "abc123")
.add_cookie("user_id", 12345)
.add_cookie("preferences", "dark_mode=true");§OpenAPI Integration
Cookies are automatically documented in the OpenAPI specification with in: cookie parameter type.
This follows the OpenAPI 3.1.0 specification for cookie parameters.
Implementations§
Source§impl CallCookies
impl CallCookies
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new empty CallCookies instance.
§Examples
use clawspec_core::CallCookies;
let cookies = CallCookies::new();
assert!(cookies.is_empty());Adds a cookie parameter to the collection.
This method follows the same pattern as CallHeaders::add_header and CallQuery::add_param,
providing a consistent API across all parameter types.
§Type Parameters
T- The cookie value type, must implementSerialize,ToSchema,Debug,Send,Sync, andClone
§Arguments
name- The cookie name (e.g., “session_id”, “user_preferences”)value- The cookie value, either a direct value or wrapped in ParamValue
§Examples
use clawspec_core::CallCookies;
let cookies = CallCookies::new()
.add_cookie("session_id", "abc123")
.add_cookie("user_id", 12345)
.add_cookie("is_admin", true);Sourcepub fn merge(self, other: Self) -> Self
pub fn merge(self, other: Self) -> Self
Merges another CallCookies instance into this one.
Cookies from the other instance will override cookies with the same name in this instance.
§Examples
use clawspec_core::CallCookies;
let cookies1 = CallCookies::new()
.add_cookie("session_id", "abc123");
let cookies2 = CallCookies::new()
.add_cookie("user_id", 456);
let merged = cookies1.merge(cookies2);
assert_eq!(merged.len(), 2);Trait Implementations§
Source§impl Clone for CallCookies
impl Clone for CallCookies
Source§fn clone(&self) -> CallCookies
fn clone(&self) -> CallCookies
1.0.0§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for CallCookies
impl Debug for CallCookies
Source§impl Default for CallCookies
impl Default for CallCookies
Source§fn default() -> CallCookies
fn default() -> CallCookies
Auto Trait Implementations§
impl Freeze for CallCookies
impl RefUnwindSafe for CallCookies
impl Send for CallCookies
impl Sync for CallCookies
impl Unpin for CallCookies
impl UnwindSafe for CallCookies
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)