Crate treasury_import

Source
Expand description

Contains everything that is required to create treasury importers library.

§Usage

struct FooImporter;

impl treasury_import::Importer for FooImporter {
    fn import(
        &self,
        source: &std::path::Path,
        output: &std::path::Path,
        _sources: &impl treasury_import::Sources,
        _dependencies: &impl treasury_import::Dependencies,
    ) -> Result<(), treasury_import::ImportError> {
        match std::fs::copy(source, output) {
          Ok(_) => Ok(()),
          Err(err) => Err(treasury_import::ImportError::Other { reason: "SOMETHING WENT WRONG".to_owned() }),
        }
    }
}


// Define all required exports.
treasury_import::make_treasury_importers_library! {
    // [extensions list]  <name> : <source-format> -> <target-format> = <expr>;
    // <expr> must have type &'static I where I: Importer
    // Use `Box::leak(importer)` if importer instance cannot be constructed in constant expression.
    [foo] foo : foo -> foo = &FooImporter;
}

Macros§

make_treasury_importers_library
Define exports required for an importers library. Accepts repetition of the following pattern: : -> = <importer expression of type [&'static impl Importer]“>

Structs§

AssetId
64-bit id value. FFI-safe.
Dependency
ImporterFFI

Enums§

ImportError
Result of Importer::import method.

Constants§

EXPORT_IMPORTERS_FN_NAME
MAGIC
MAGIC_NAME
VERSION_FN_NAME

Traits§

Dependencies
Importer
Trait for an importer.
Sources

Functions§

ensure_dependencies
ensure_sources
version

Type Aliases§

ExportImportersFnType
MagicType
VersionFnType