pub struct Session { /* private fields */ }Expand description
Cookie, score, and user-data state associated with a crawling identity.
use millipede_core::session::{Session, SessionConfig};
let session = Session::new(SessionConfig::default());
assert!(session.id().as_str().starts_with("session-"));Implementations§
Source§impl Session
impl Session
Sourcepub fn new(config: SessionConfig) -> Self
pub fn new(config: SessionConfig) -> Self
Creates an empty session with a generated identifier.
Returns the authoritative shared cookie jar.
Sourcepub async fn with_user_data<R>(&self, f: impl FnOnce(&UserData) -> R) -> R
pub async fn with_user_data<R>(&self, f: impl FnOnce(&UserData) -> R) -> R
Reads user data through a synchronous closure, releasing the lock on return.
Sourcepub async fn update_user_data(&self, f: impl FnOnce(&mut UserData))
pub async fn update_user_data(&self, f: impl FnOnce(&mut UserData))
Mutates user data through a synchronous closure, releasing the lock on return.
Sourcepub async fn error_score(&self) -> f32
pub async fn error_score(&self) -> f32
Returns the error score in unscaled units.
Sourcepub async fn usage_count(&self) -> u32
pub async fn usage_count(&self) -> u32
Returns the number of attempts served.
Sourcepub async fn record_usage(&self)
pub async fn record_usage(&self)
Records one checkout attempt. Session pools call this when serving a session.
Sourcepub async fn is_blocked(&self) -> bool
pub async fn is_blocked(&self) -> bool
Returns whether the error threshold has been reached.
Sourcepub fn is_expired(&self) -> bool
pub fn is_expired(&self) -> bool
Returns whether the fixed creation-time expiry has passed.
Sourcepub async fn is_retired(&self) -> bool
pub async fn is_retired(&self) -> bool
Returns whether the session was explicitly retired.
Stores Set-Cookie headers synchronously and infallibly.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Session
impl !RefUnwindSafe for Session
impl !UnwindSafe for Session
impl Send for Session
impl Sync for Session
impl Unpin for Session
impl UnsafeUnpin for Session
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
Mutably borrows from an owned value. Read more