Struct CookieJar
pub struct CookieJar { /* private fields */ }
Expand description
Provides automatic cookie session management using an in-memory cookie store.
Cookie jars are designed to be shareable across many concurrent requests, so cloning the jar simply returns a new reference to the jar instead of doing a deep clone.
This cookie jar implementation seeks to conform to the rules for client state management as described in RFC 6265.
§Domain isolation
Cookies are isolated from each other based on the domain and path they are received from. As such, most methods require you to specify a URI, since unrelated websites can have cookies with the same name without conflict.
Implementations§
§impl CookieJar
impl CookieJar
pub fn get_by_name(&self, uri: &Uri, cookie_name: &str) -> Option<Cookie>
pub fn get_by_name(&self, uri: &Uri, cookie_name: &str) -> Option<Cookie>
Get a cookie by name for the given URI.
pub fn get_for_uri(&self, uri: &Uri) -> impl IntoIterator<Item = Cookie>
pub fn get_for_uri(&self, uri: &Uri) -> impl IntoIterator<Item = Cookie>
Get a copy of all the cookies in the jar that match the given URI.
The returned collection contains a copy of all the cookies matching the URI at the time this function was called. The collection is not a “live” view into the cookie jar; concurrent changes made to the jar (cookies inserted or removed) will not be reflected in the collection.
pub fn clear(&self)
pub fn clear(&self)
Remove all cookies from this cookie jar.
pub fn set(
&self,
cookie: Cookie,
request_uri: &Uri,
) -> Result<Option<Cookie>, CookieRejectedError>
pub fn set( &self, cookie: Cookie, request_uri: &Uri, ) -> Result<Option<Cookie>, CookieRejectedError>
Set a cookie for the given absolute request URI.
If the cookie was set successfully, returns the cookie that previously existed for the given domain, path, and cookie name, if any.
If unsuccessful, returns a [CookieRejectedError
] which can be used to get back the
attempted cookie.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for CookieJar
impl RefUnwindSafe for CookieJar
impl Send for CookieJar
impl Sync for CookieJar
impl Unpin for CookieJar
impl UnwindSafe for CookieJar
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more