Module perseus::template

source ·
Expand description

Utilities for working with templates and state generation. This is by far the module you’ll probably access the most.

Structs

  • 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 equivalent of TemplateInner for capsules.
  • 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.
  • The internal representation of a Perseus template, with all the methods involved in creating and managing it. As this struct is not Clone, it will almost always appear wrapped in a full Template, which allows cloning and passing the template around arbitrarily. As that dereferences to this, you will be able to use any of the methods on this struct on Template.

Enums

  • The same as GeneratorResult, except this uses a GenericBlamedError as its error type, which is essentially a Boxed generic error with an attached ErrorBlame denoting who is responsible for the error: the client or the server. You’ll see this as a convertion type in the signatures of functions that might be run at reuqest-time (e.g. get_request_state might have an error caused by a missing file, which would be the server’s fault, or a malformed cookie, which would be the client’s fault).
  • A custom enum representation of a Result-style type whose error is a Box that can accept any thread-safe error type. This is used internally as a conversion type so that your state generation functions (e.g. get_build_state) can return either some type T, or a Result<T, E>, where E is of your choosing. This type appears as Into<GeneratorResult<T>> in several function signatures, and that From/Into relation is automatically implemented for all the types you’ll need in your state generation functions.