pub struct ImmutableStore { /* private fields */ }
Expand description

An immutable storage system used by Perseus’ engine to store build artifacts and the like, which will then be used by the server or the export process. By default, this is set to a path inside the dist/ folder at the root of your project, which you should only change if you have special requirements, as the CLI expects the default paths to be used, with no option for customization yet.

Note that this is only used for immutable data, which can be read-only in production, meaning there are no consequences of using this on a read-only production filesystem (e.g. in a serverless function). Data that do need to change use a MutableStore instead.

Implementations§

source§

impl ImmutableStore

source

pub fn new(root_path: String) -> Self

Creates a new immutable store. You should provide a path like dist here. Note that any trailing slashes will be automatically stripped.

source

pub fn get_path(&self) -> &str

Gets the filesystem path used for this immutable store.

This is designed to be used in particular by the engine to work out where to put static assets and the like when exporting.

source

pub async fn read(&self, name: &str) -> Result<String, StoreError>

Reads the given asset from the filesystem asynchronously.

source

pub async fn write(&self, name: &str, content: &str) -> Result<(), StoreError>

Writes the given asset to the filesystem asynchronously. This must only be used at build-time, and must not be changed afterward. Note that this will automatically create any missing parent directories.

Trait Implementations§

source§

impl Clone for ImmutableStore

source§

fn clone(&self) -> ImmutableStore

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for ImmutableStore

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.