Expand description
A series of imports needed by most Perseus apps, in some form. This should be used in conjunction with the Sycamore prelude.
Re-exports
pub use crate::engine;
pub use crate::template;
pub use crate::ErrorCause;
pub use crate::ErrorPages;
pub use crate::GenericErrorWithCause;
Macros
Logs the given
format!
-style data to the browser’s console, or to stdout
on the server.Structs
A single template in an app. Each template is comprised of a Sycamore view,
a state type, and some functions involved with generating that state. Pages
can then be generated from particular states. For instance, a single
docs
template could have a state struct
that stores a title and some content,
which could then render as many pages as desired.Functions
The component that represents the entrypoint at which Perseus will inject
itself. You can use this with the
.index_view()
method of
PerseusAppBase
to avoid having to create the entrypoint <div>
manually.Same as
cache_res
, but takes a function that returns a Result
, allowing
you to use ?
and the like inside your logic.Runs the given function once and then caches the result to the filesystem
for future execution. Think of this as filesystem-level memoizing. In
future, this will be broken out into its own crate and wrapped by Perseus.
The second parameter to this allows forcing the function to re-fetch data
every time, which is useful if you want to revalidate data or test
your fetching logic again. Note that a change to the logic will not trigger
a reload unless you make it do so. For this reason, it’s recommended to only
use this wrapper once you’ve tested your fetching logic.
Type Definitions
An alias for the usual kind of Perseus app, which uses the filesystem-based
mutable store and translations manager. See
PerseusAppBase
for details.A generic error type that can be adapted for any errors the user may want to
return from a render function.
.into()
can be used to convert most error
types into this without further hassle. Otherwise, use Box::new()
on the
type.A generic error type that can be adapted for any errors the user may want to
return from a render function, as with
RenderFnResult<T>
. However, this
also includes a mandatory statement of causation for any errors, which
assigns blame for them to either the client or the server. In cases where
this is ambiguous, this allows returning accurate HTTP status codes.Attribute Macros
Annotates functions used for amalgamating build-time and request-time states
to support automatic serialization/deserialization of app state and
client/server division. This supersedes the old
autoserde
macro for state
amalgamation functions.Marks the annotated code as only to be run in the browser. This is the
opposite of (and mutually exclusive with)
#[engine]
. This resolves to a
target-gate that makes the annotated code run only on targets that are
wasm32
.Marks the given function as the browser entrypoint into your app. This is
designed for more complex apps that need to manually distinguish between the
engine and browser entrypoints.
Annotates functions used for generating paths at build time to support
automatic serialization/deserialization of app state and client/server
division. This supersedes the old
autoserde
macro for build paths
functions.Annotates functions used for generating state at build time to support
automatic serialization/deserialization of app state and client/server
division. This supersedes the old
autoserde
macro for build state
functions.Marks the annotated code as only to be run as part of the engine (the
server, the builder, the exporter, etc.). This resolves to a target-gate
that makes the annotated code run only on targets that are not
wasm32
.Marks the given function as the engine entrypoint into your app. This is
designed for more complex apps that need to manually distinguish between the
engine and browser entrypoints.
Annotates functions used for generating global state at build time to
support automatic serialization/deserialization of app state and
client/server division. This supersedes the old
autoserde
macro for global
build state functions.Labels a function as a Perseus head function, which is very similar to a
template, but for the HTML metadata in the document
<head>
.Marks the given function as the universal entrypoint into your app. This is
designed for simple use-cases, and the annotated function should return
a
PerseusApp
. This will expand into separate main()
functions for both
the browser and engine sides.This is identical to
#[main]
, except it doesn’t require a server
integration, because it sets your app up for exporting only. This is useful
for apps not using server-requiring features (like incremental static
generation and revalidation) that want to avoid bringing in another
dependency on the server-side.Processes the given
struct
to create a reactive version by wrapping each
field in a Signal
. This will generate a new struct
with the given name
and implement a .make_rx()
method on the original that allows turning an
instance of the unreactive struct
into an instance of the reactive one.Annotates functions used for generating state at request time to support
automatic serialization/deserialization of app state and client/server
division. This supersedes the old
autoserde
macro for request state
functions.Annotates functions used for generating state at build time to support
automatic serialization/deserialization of app state and client/server
division. This supersedes the old
autoserde
macro for build state
functions.Annotates functions used for checking if a template should revalidate and
request-time states to support automatic serialization/deserialization
of app state and client/server division. This supersedes the old
autoserde
macro for revalidation determination functions.Labels a Sycamore component as a Perseus template, turning it into something
that can be easily inserted into the
.template()
function, avoiding the
need for you to manually serialize/deserialize things. This should be
provided the name of the Sycamore component (same as given to Sycamore’s
#[component()]
, but without the <G>
).The new version of
#[template]
designed for reactive state. This can
interface automatically with global state, and will automatically provide
Sycamore #[component]
annotations. To use this, you don’t need to provide
anything other than an optional custom type parameter letter (by default,
G
will be used). Unlike with the original macro, this will automatically
handle component names internally.Marks the given function as a Perseus test. Functions marked with this
attribute must have the following signature:
async fn foo(client: &mut fantoccini::Client) -> Result<>
.