Skip to main content

RenderOptions

Struct RenderOptions 

Source
pub struct RenderOptions<'a> {
    pub entry_id: &'a str,
    pub request_path: &'a str,
    pub nonce: Option<&'a str>,
    pub head_inject: Option<&'a str>,
    pub body_inject: Option<&'a str>,
}
Expand description

Options controlling how the handler renders a protocol.

The handler performs server-side route matching: matched routes are rendered visible with content; non-matched routes are rendered hidden and empty.

Fields§

§entry_id: &'a str

The fragment ID to start rendering from (e.g., "index.html").

§request_path: &'a str

The URL path to match routes against (e.g., "/contacts/42").

§nonce: Option<&'a str>

Optional CSP nonce for inline <script> tags. When set, all inline scripts include nonce="VALUE" and a <meta name="webui-nonce"> tag is emitted for the client router.

§head_inject: Option<&'a str>

Optional HTML to emit immediately before the document’s </head> close. Used for per-request <link rel="preload"> hints, CSP <meta> tags beyond the built-in nonce, etc. Inserted at the structural head_end boundary identified by the parser — never matched against a byte pattern, so cannot be tricked by </head> literals appearing in HTML comments, srcdoc attributes, or inline scripts.

§body_inject: Option<&'a str>

Optional HTML to emit immediately before the document’s </body> close. Used for dev livereload <script>, analytics snippets, OpenTelemetry trace IDs, etc. Same structural-boundary guarantee as head_inject.

Implementations§

Source§

impl<'a> RenderOptions<'a>

Source

pub fn new(entry_id: &'a str, request_path: &'a str) -> RenderOptions<'a>

Create render options for the given entry fragment and request path.

Source

pub fn with_nonce(self, nonce: &'a str) -> RenderOptions<'a>

Set the CSP nonce for inline scripts. Pass an empty string to disable (None semantics) — empty <meta name="webui-nonce" content=""> would be browser-ignored noise.

Source

pub fn with_head_inject(self, html: &'a str) -> RenderOptions<'a>

Set HTML to emit immediately before </head>. Pass an empty string to disable (None semantics).

§Safety (XSS warning)

The provided HTML is written verbatim — no HTML escaping is performed. Callers MUST ensure the content is fully trusted (typically a &'static str or build-time-derived bytes such as dev livereload script, image preload <link> tags, or A/B test markers). Passing user-controlled or attacker-influenced content here is a direct cross-site scripting vulnerability. If your caller path may include untrusted data, escape with the host’s HTML escaper (e.g. webui_handler::encode_safe) before calling this builder.

Source

pub fn with_body_inject(self, html: &'a str) -> RenderOptions<'a>

Set HTML to emit immediately before </body>. Pass an empty string to disable (None semantics).

§Safety (XSS warning)

Same contract as with_head_inject: the HTML is written verbatim with no escaping, so callers MUST ensure the content is fully trusted. Untrusted content is a direct XSS vector.

Auto Trait Implementations§

§

impl<'a> Freeze for RenderOptions<'a>

§

impl<'a> RefUnwindSafe for RenderOptions<'a>

§

impl<'a> Send for RenderOptions<'a>

§

impl<'a> Sync for RenderOptions<'a>

§

impl<'a> Unpin for RenderOptions<'a>

§

impl<'a> UnsafeUnpin for RenderOptions<'a>

§

impl<'a> UnwindSafe for RenderOptions<'a>

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.