Skip to main content

RouterBuilderRuntimeExt

Trait RouterBuilderRuntimeExt 

Source
pub trait RouterBuilderRuntimeExt {
    // Required methods
    fn runtime(self) -> Self;
    fn prefetch(self, mode: PrefetchMode) -> Self;
    fn max_runs_per_connection(self, max: usize) -> Self;
}
Available on crate feature router only.
Expand description

Sets up the browser runtime on a RouterBuilder.

Required Methods§

Source

fn runtime(self) -> Self

Enables page reruns by registering a RuntimeLayer.

Call this once when building a router that serves interactive pages. Register your application’s pathless layers first so the runtime layer can rewrite page reruns to GET before those layers run. See RuntimeLayer for the request format and rewrite behavior.

Register procedures and shards separately through discovery or explicit registration.

Source

fn prefetch(self, mode: PrefetchMode) -> Self

Sets when links in this router load their pages ahead of time.

This sets the app context value read by prefetch_mode. You can override it with a PrefetchMode in the request context or with a link’s prefetch argument.

use topcoat_router::Router;
use topcoat_runtime::{PrefetchMode, RouterBuilderRuntimeExt};

let router = Router::builder()
    .runtime()
    .prefetch(PrefetchMode::Viewport)
    .build();
§Panics

Panics if the app context already contains a PrefetchMode.

Source

fn max_runs_per_connection(self, max: usize) -> Self

Sets how many connected renders one runtime connection may have at once. The default is 64.

The browser keeps one connected render for each live page or shard that is not inside another one. Once a connection reaches the limit, the server answers further render requests with 429 Too Many Requests until a render finishes or is stopped.

use topcoat_router::Router;
use topcoat_runtime::RouterBuilderRuntimeExt;

let router = Router::builder()
    .runtime()
    .max_runs_per_connection(128)
    .build();
§Panics

Panics if the limit was already set.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl RouterBuilderRuntimeExt for RouterBuilder

Source§

fn runtime(self) -> Self

Source§

fn prefetch(self, mode: PrefetchMode) -> Self

Source§

fn max_runs_per_connection(self, max: usize) -> Self

Implementors§