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::error_views::ErrorViews;
pub use crate::errors::BlamedError;
pub use crate::errors::ErrorBlame;
pub use crate::reactor::Reactor;
pub use crate::PerseusNodeType;
pub use crate::Request;
Macros
Logs the given
format!
-style data to the browser’s console, or to stdout
on the server.Structs
The output of the build seed system, which should be generated by a user
function for each template.
A capsule, a special type of template in Perseus that can also accept
properties. Capsules are basically a very special type of Sycamore
component that can integrate fully with Perseus’ state platform, generating
their own states at build-time, request-time, etc. They’re then used in one
or more pages, and provided extra properties.
The options for constructing a Perseus app. This
struct
will tie
together all your code, declaring to Perseus where your templates,
error pages, static content, etc. are.A wrapper for fallible reactive state.
The intermediate reactive type for
RxResult
. You shouldn’t need to
interface with this manually.An analogue of
std::convert::Infallible
that can be serialized and
deserialized, since Serde currently does not implement those traits on the
standard library’s Infallible
. Until this issue is
resolved, this must be used instead in the state platform.The information any function that generates state will be provided.
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.Traits
Trait that is implemented by all [
GenericNode
] backends that render to HTML.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.
Marks a checkpoint in the code and alerts any tests that it’s been reached
by creating an element that represents it. The preferred solution would be
emitting a DOM event, but the WebDriver specification currently doesn’t
support waiting on those (go figure). This will only create a custom element
if the
__PERSEUS_TESTING
JS global variable is set to true
.Navigates to the specified
url
. The url should have the same origin as the app.Navigates to the specified
url
without adding a new history entry. Instead, this replaces the
current location with the new url
. The url should have the same origin as the app.Spawns a
!Send
future on the current scope. If the scope is destroyed before the future is
completed, it is aborted immediately. This ensures that it is impossible to access any
values referencing the scope after they are destroyed.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.An alias for a Perseus app that uses a custom mutable store type. See
PerseusAppBase
for details.An alias for a fully customizable Perseus app that can accept a custom
mutable store and a custom translations manager. Alternatively, you could
just use
PerseusAppBase
directly.An alias for a Perseus app that uses a custom translations manager type. See
PerseusAppBase
for details.Attribute Macros
A helper macro for templates that use reactive state. Once, this was needed
on all Perseus templates, however, today, templates that take no state, or
templates that take unreactive state, can be provided as normal functions
to the methods
.view()
and .view_with_unreactive_state()
respectively, on Perseus’ Template
type.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.
A convenience macro that makes sure the given function is only defined on
the browser-side, creating an empty function on the engine-side. Perseus
implicitly expects your browser-side state modification functions to be
defined in this way (though you certainly don’t have to use this macro).
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.
A convenience macro that makes sure the given function is only defined on
the engine-side, creating an empty function on the browser-side. Perseus
implicitly expects most of your state generation functions to be defined in
this way (though you certainly don’t have to use this macro).
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.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<>
.Derive Macros
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.