Rust

rendering

Module

Rendering: Rendering, server-side (Ssr) and static (Static) output, and the RenderingDetector that tells them apart from a build's files.

Contents

use utopia_detector::RenderingDetector;
Rust
pub struct RenderingDetector

Tells how a framework's build is served from the build's file names: the first option, in the order they were added, with one of its files for the framework among the inputs; otherwise static output, falling back to the only HTML file when there is exactly one.

Rust
use utopia_detector::{RenderingDetector, Ssr, Static};

let mut detector = RenderingDetector::new("nextjs");
detector.add_option(Ssr::new()).add_option(Static::new());
detector.add_input("server/pages/index.html").add_input("server/pages/api/users.js");

let rendering = detector.detect();
assert_eq!(rendering.name(), "static");
assert_eq!(rendering.fallback_file(), Some("server/pages/index.html"));
Also implements Debug.
use utopia_detector::Ssr;
Rust
pub struct Ssr

Server-side rendering: the build has a server entry for the framework.

use utopia_detector::Static;
Rust
pub struct Static

Static output: plain files, with an optional fallback page.

use utopia_detector::Rendered;
Rust
pub enum Rendered<'a>

What a RenderingDetector found: one of its options, or static output it made up because none matched.

use utopia_detector::Rendering;
Rust
pub trait Rendering: Send + Sync

How a framework's build output is served, recognised by the files the build leaves for a given framework.

Implemented bySsrStatic