pub struct WebSession(/* private fields */);Expand description
A retained browsing session: the thing that outlives the view showing it.
Day rebuilds a page’s whole subtree on every navigation, so a plain web_view gets a brand-new
native view each visit and reloads from scratch. A session moves the engine out of that
lifetime: the piece keeps the native web view alive against this id, and a later web_view
bound to the same session re-attaches it with its page, scroll position, history and JavaScript
context intact.
This is the shape Apple settled on for the same problem (WebPage holds the session and
WebView renders it), and the reason it works is the same: a web view’s content lives in the
object and its content process, not in its attachment to a parent view.
Sessions are keyed by a &'static str, so WebSession::global is idempotent and safe to
call from a page function that runs again on every navigation. There is no way to mint an
anonymous one: an id that changed per build would retain a new view each visit and leak them
all.
The retained view is never freed: one session is one live web view for the process’s lifetime. Use them for pages a user returns to, not per-item.
Implementations§
Source§impl WebSession
impl WebSession
Sourcepub fn global(key: &'static str) -> WebSession
pub fn global(key: &'static str) -> WebSession
The session named key, created on first use. Calling this repeatedly with the same key
returns the same session.
Sourcepub fn id(self) -> u64
pub fn id(self) -> u64
The raw id, as it reaches a backend arm through WebProps::session.
Trait Implementations§
Source§impl Clone for WebSession
impl Clone for WebSession
impl Copy for WebSession
Source§impl Debug for WebSession
impl Debug for WebSession
impl Eq for WebSession
Source§impl PartialEq for WebSession
impl PartialEq for WebSession
impl StructuralPartialEq for WebSession
Auto Trait Implementations§
impl Freeze for WebSession
impl RefUnwindSafe for WebSession
impl Send for WebSession
impl Sync for WebSession
impl Unpin for WebSession
impl UnsafeUnpin for WebSession
impl UnwindSafe for WebSession
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,
impl<T> ErasedDestructor for Twhere
T: 'static,
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