SsrSharedContext

Struct SsrSharedContext 

Source
pub struct SsrSharedContext { /* private fields */ }
Expand description

The shared context that should be used on the server side.

Implementations§

Source§

impl SsrSharedContext

Source

pub fn new() -> Self

Creates a new shared context for rendering HTML on the server.

Source

pub fn new_islands() -> Self

Creates a new shared context for rendering HTML on the server in “islands” mode.

This defaults to a mode in which the app is not hydrated, but allows you to opt into hydration for certain portions using SharedContext::set_is_hydrating.

Source

pub async fn consume_buffers(&self) -> Vec<(SerializedDataId, String)>

Consume the data buffers, awaiting all async resources, returning both sync and async buffers. Useful to implement custom hydration contexts.

WARNING: this will clear the internal buffers, it should only be called once. A second call would return an empty vec![].

Trait Implementations§

Source§

impl Debug for SsrSharedContext

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for SsrSharedContext

Source§

fn default() -> SsrSharedContext

Returns the “default value” for a type. Read more
Source§

impl SharedContext for SsrSharedContext

Source§

fn is_browser(&self) -> bool

Whether the application is running in the browser.
Source§

fn next_id(&self) -> SerializedDataId

Returns the next in a series of IDs that is unique to a particular request and response. Read more
Source§

fn write_async(&self, id: SerializedDataId, fut: PinnedFuture<String>)

The given Future should resolve with some data that can be serialized from the server to the client. This will be polled as part of the process of building the HTTP response, not when it is first created. Read more
Source§

fn read_data(&self, _id: &SerializedDataId) -> Option<String>

Reads the current value of some data from the shared context, if it has been sent from the server. This returns the serialized data as a String that should be deserialized. Read more
Source§

fn await_data(&self, _id: &SerializedDataId) -> Option<String>

Returns a Future that resolves with a String that should be deserialized once the given piece of server data has resolved. Read more
Source§

fn get_is_hydrating(&self) -> bool

Returns true if you are currently in a part of the application tree that should be hydrated. Read more
Source§

fn set_is_hydrating(&self, is_hydrating: bool)

Sets whether you are currently in a part of the application tree that should be hydrated. Read more
Source§

fn errors(&self, boundary_id: &SerializedDataId) -> Vec<(ErrorId, Error)>

Returns the set of errors that have been registered with a particular boundary.
Source§

fn register_error( &self, error_boundary_id: SerializedDataId, error_id: ErrorId, error: Error, )

Registers an error with the context to be shared from server to client.
Source§

fn take_errors(&self) -> Vec<(SerializedDataId, ErrorId, Error)>

Returns all errors that have been registered, removing them from the list.
Source§

fn seal_errors(&self, boundary_id: &SerializedDataId)

“Seals” an error boundary, preventing further errors from being registered for it. Read more
Source§

fn pending_data(&self) -> Option<PinnedStream<String>>

Returns some Stream of HTML that contains JavaScript <script> tags defining all values being serialized from the server to the client, with their serialized values and any boilerplate needed to notify a running application that they exist; or None. Read more
Source§

fn during_hydration(&self) -> bool

Whether the page is currently being hydrated. Read more
Source§

fn hydration_complete(&self)

Tells the shared context that the hydration process is complete.
Source§

fn defer_stream(&self, wait_for: PinnedFuture<()>)

Adds a Future to the set of “blocking resources” that should prevent the server’s response stream from beginning until all are resolved. The Future returned by blocking resources will not resolve until every Future added by this method has resolved. Read more
Source§

fn await_deferred(&self) -> Option<PinnedFuture<()>>

Returns a Future that will resolve when every Future added via defer_stream has resolved. Read more
Source§

fn set_incomplete_chunk(&self, id: SerializedDataId)

Tells the client that this chunk is being sent from the server before all its data have loaded, and it may be in a fallback state.
Source§

fn get_incomplete_chunk(&self, id: &SerializedDataId) -> bool

Checks whether this chunk is being sent from the server before all its data have loaded.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.