pub struct SessionSnapshot {
pub origin: String,
pub cookies: Vec<SessionCookie>,
pub local_storage: HashMap<String, String>,
pub captured_at: u64,
pub ttl_secs: Option<u64>,
}Expand description
A point-in-time snapshot of a browser session.
Contains cookies and localStorage entries that are sufficient to resume most authenticated sessions.
Fields§
§origin: StringOrigin URL the session was captured from (e.g. "https://example.com").
Saved cookies.
local_storage: HashMap<String, String>localStorage key-value pairs captured from the page.
captured_at: u64Unix timestamp (seconds) when this snapshot was captured.
ttl_secs: Option<u64>Approximate TTL for auto-expiry checks. None means never expire.
Implementations§
Source§impl SessionSnapshot
impl SessionSnapshot
Sourcepub fn is_expired(&self) -> bool
pub fn is_expired(&self) -> bool
Returns true if the snapshot has exceeded its TTL.
Always returns false when no TTL is set.
Sourcepub fn save_to_file(&self, path: impl AsRef<Path>) -> Result<()>
pub fn save_to_file(&self, path: impl AsRef<Path>) -> Result<()>
Serialise to a JSON file.
§Errors
Returns an IO or serialisation error if the file cannot be written.
Sourcepub fn load_from_file(path: impl AsRef<Path>) -> Result<Self>
pub fn load_from_file(path: impl AsRef<Path>) -> Result<Self>
Deserialise from a JSON file previously written by Self::save_to_file.
§Errors
Returns an IO or deserialisation error if the file cannot be read.
Trait Implementations§
Source§impl Clone for SessionSnapshot
impl Clone for SessionSnapshot
Source§fn clone(&self) -> SessionSnapshot
fn clone(&self) -> SessionSnapshot
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SessionSnapshot
impl Debug for SessionSnapshot
Source§impl<'de> Deserialize<'de> for SessionSnapshot
impl<'de> Deserialize<'de> for SessionSnapshot
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for SessionSnapshot
impl RefUnwindSafe for SessionSnapshot
impl Send for SessionSnapshot
impl Sync for SessionSnapshot
impl Unpin for SessionSnapshot
impl UnwindSafe for SessionSnapshot
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