pub struct RenderingDetector { /* private fields */ }Expand description
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.
PHP: Utopia\Detector\Detector\Rendering.
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"));use Utopia\Detector\Detection\Rendering\SSR;
use Utopia\Detector\Detection\Rendering\XStatic;
use Utopia\Detector\Detector\Rendering;
$detector = new Rendering('nextjs');
$detector->addOption(new SSR())->addOption(new XStatic());
$detector->addInput('server/pages/index.html')->addInput('server/pages/api/users.js');
$rendering = $detector->detect();
echo $rendering->getName(), "\n"; // static
echo $rendering->getFallbackFile(), "\n"; // server/pages/index.htmlImplementations§
Source§impl RenderingDetector
impl RenderingDetector
Sourcepub fn new(framework: impl Into<String>) -> Self
pub fn new(framework: impl Into<String>) -> Self
A detector for the build of framework (a framework name, such as
nextjs).
PHP: new Rendering($framework).
Sourcepub fn add_option(&mut self, option: impl Rendering + 'static) -> &mut Self
pub fn add_option(&mut self, option: impl Rendering + 'static) -> &mut Self
Adds a rendering, tried after the others.
PHP: addOption($rendering).
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for RenderingDetector
impl !UnwindSafe for RenderingDetector
impl Forget for RenderingDetector
impl Freeze for RenderingDetector
impl Move for RenderingDetector
impl Send for RenderingDetector
impl Sync for RenderingDetector
impl Unpin for RenderingDetector
impl UnsafeUnpin for RenderingDetector
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
Mutably borrows from an owned value. Read more