Crate ript

Source
Expand description

ript is a crate for implementing a Rusty version of the Inertia.js protocol as a layer on top of Axum. This provides 100% conformity to the inertia protocol and is directly compatible with the inertiajs javascript package, while providing an additional feature set and a more ergonomic API for rust. Additionally, ript implements some things differently from the original Laravel implementation, such as different error handling around validation.

To get started with ript, simply set up an axum server like normal, and then add a response middleware utilizing the crate::driver::driver function.

Then, you can write any handlers you desire using the crate::Inertia extractor.

Re-exports§

pub use axum;

Structs§

Inertia
The entrypoint to Inertia that is used by route handlers and response mapping middleware.
RenderResponse
Inertia response when rendering a page.

Traits§

Riptc
Marker trait for types that should be scanned by riptc despite not being a direct dependency of a route.

Functions§

always
This prop should always be sent back, regardless of if the request is partial or if the prop has been asked for. Only use this on data that is very cheap to calculate, or you may run into performance issues depending on how agressively you reload the page.
defer
This prop should be deferred during a full reload, and sent back during a partial reload if it is requested. The defer logic is automatically implemented by the InertiaJS client for you, so if you’re using a deferred prop it will automatically work.
driver
Axum map response function for powering inertia.
infallible
Since all props must be either a Result or an Option, this provides a utility to wrap a non-result type as an infallible Result. This means it will never abort and hit the error handling response middleware, nor will it become nullable
lazy
This prop should only be rendered if explicitly requested in a partial reload, and be null otherwise.
merge
This prop should be merged with the previous value of the prop set, if it exists. The merging logic itself is completely handled by the InertiaJS client, so all this really does is flag the prop to be merged but it will behave like a regular prop otherwise. This can be combined with other methods at-will.
null
Another helper type that simply omits a type. This is useful for if you have two different render branches, and one must include something but one must not and avoids you having to turbofish.

Derive Macros§

Riptc
Indicates to riptc that a type should be generated and shared despite not being a direct dependency of a route that we have detected.