simvx.core.assets.loaders.base

Loader base class: parses raw bytes from a Source into a typed asset.

Each Loader owns its own LRU cache keyed on (uri, version). The

class:

AssetServer looks up the loader either by URI suffix (.png → texture loader) or by the explicit loader= argument passed to server.load(...).

Module Contents

Classes

Loader

Base class for asset-type loaders.

Data

API

class simvx.core.assets.loaders.base.Loader(*, cache_bytes: int = 256 * 1024 * 1024)[source]

Base class for asset-type loaders.

Subclasses override :meth:parse to convert raw bytes into a typed asset. The base class handles caching, size estimation, and the cache opt-out.

Initialization

suffixes: tuple[str, ...]

()

parse(raw: bytes, uri: str) Any[source]

Convert raw bytes from a Source into the typed asset.

Override in subclasses. The default returns the bytes unchanged (used by :class:BytesLoader).

get_cached(uri: str, version: str | None) Any | None[source]
store(uri: str, version: str | None, value: Any) None[source]
claims(uri: str) bool[source]

Return True if this loader handles uri by suffix.

AssetServer iterates registered loaders and picks the first one that claims the URI; falls back to :class:BytesLoader.

simvx.core.assets.loaders.base.LoaderFunc

None