Expand description

General utilities that may be useful while building Perseus apps.

Structs

Represents a duration that can be computed relative to the current time.

A simpler representation of a duration based on individual components.

An error type for invalid String durations.

Functions

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.

Gets the path prefix to apply on the server. This uses the PERSEUS_BASE_PATH environment variable, which avoids hardcoding something as changeable as this into the final binary. Hence however, that variable must be the same as what’s set in <base> (done automatically). Trailing forward slashes will be trimmed automatically.