Skip to main content

RegistryContainerExt

Trait RegistryContainerExt 

Source
pub trait RegistryContainerExt: Sized {
    // Required methods
    fn serialize_to_string(&self) -> Result<String, FileError>;
    async fn load_from_file(
        path: &Path,
        resource_io: &(dyn ResourceIo + 'static),
    ) -> Result<Self, FileError>;
    async fn save(
        &self,
        path: &Path,
        resource_io: &(dyn ResourceIo + 'static),
    ) -> Result<(), FileError>;
    fn save_sync(
        &self,
        path: &Path,
        resource_io: &(dyn ResourceIo + 'static),
    ) -> Result<(), FileError>;
}
Expand description

An extension trait with save/load methods.

Required Methods§

Source

fn serialize_to_string(&self) -> Result<String, FileError>

Serializes the registry into a formatted string.

Source

async fn load_from_file( path: &Path, resource_io: &(dyn ResourceIo + 'static), ) -> Result<Self, FileError>

Tries to load a registry from a file using the specified resource IO. This method is intended to be used only in async contexts.

Source

async fn save( &self, path: &Path, resource_io: &(dyn ResourceIo + 'static), ) -> Result<(), FileError>

Tries to save the registry into a file using the specified resource IO. This method is intended to be used only in async contexts.

Source

fn save_sync( &self, path: &Path, resource_io: &(dyn ResourceIo + 'static), ) -> Result<(), FileError>

Same as Self::save, but synchronous.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl RegistryContainerExt for BTreeMap<Uuid, PathBuf>

Source§

fn serialize_to_string(&self) -> Result<String, FileError>

Source§

async fn load_from_file( path: &Path, resource_io: &(dyn ResourceIo + 'static), ) -> Result<BTreeMap<Uuid, PathBuf>, FileError>

Source§

async fn save( &self, path: &Path, resource_io: &(dyn ResourceIo + 'static), ) -> Result<(), FileError>

Source§

fn save_sync( &self, path: &Path, resource_io: &(dyn ResourceIo + 'static), ) -> Result<(), FileError>

Implementors§