pub struct ServerState {
pub mount_config: MountConfig,
pub port_watch: Option<u16>,
/* private fields */
}Fields§
§mount_config: MountConfig§port_watch: Option<u16>Implementations§
Source§impl ServerState
impl ServerState
pub fn init(mount_config: &MountConfig) -> Result<(), ErrorCode>
pub fn init_with_watch( mount_config: &MountConfig, port_watch: Option<u16>, ) -> Result<(), ErrorCode>
Sourcepub fn module_compile_time(&self) -> Duration
pub fn module_compile_time(&self) -> Duration
How long compiling this mount point’s wasm module took, at startup.
pub fn global(mount_point: &str) -> Arc<ServerState> ⓘ
pub async fn request(&self, url: &str) -> ResponseState
ServerState::request for a browser request that carried cookies.
cookie is the request’s Cookie header. It goes out with every SSR fetch to the
server’s own origin (a relative URL, resolved against ssr_fetch_base), as the browser
sends it with a same-origin fetch - so an API behind a session answers for the
logged-in user and the page renders as it will look after hydration. Fetches to other
origins never get it.
The app itself can read during SSR only the cookies named with
MountConfigBuilder::ssr_cookie
(get_driver().cookie_get() returns nothing for the others): the header doesn’t say which
cookies are HttpOnly, and those are hidden from the browser’s document.cookie, so
exposing them would render differently than the browser can.
Sourcepub async fn request_with_headers(
&self,
url: &str,
headers: RequestHeaders<'_>,
) -> ResponseState
pub async fn request_with_headers( &self, url: &str, headers: RequestHeaders<'_>, ) -> ResponseState
ServerState::request for a browser request, with the headers that change the page:
the cookies, as in ServerState::request_with_cookie, and the languages the browser
prefers, which get_driver().languages() tells the app.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for ServerState
impl !UnwindSafe for ServerState
impl Freeze for ServerState
impl Send for ServerState
impl Sync for ServerState
impl Unpin for ServerState
impl UnsafeUnpin for ServerState
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§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