Documentation
¶
Index ¶
- Constants
- Variables
- func Default() (fs.FS, string, bool)
- func LoadDefaultPackage(name string) error
- func MarshalCatalog(catalog Catalog) ([]byte, error)
- func MountDefaultPackage(name string, data []byte) error
- func OpenDirectory(root string) fs.FS
- func SetDefault(source fs.FS, root string) error
- func SetDefaultProject(source fs.FS, root string) error
- func Size(name string) (float64, float64, error)
- func Sub(source fs.FS, dir string) (fs.FS, error)
- func ValidPackageName(name string) bool
- type AssetInfo
- type Blob
- func (b *Blob) Bytes() ([]byte, error)
- func (b *Blob) Close() error
- func (b *Blob) ContentID() ContentID
- func (b *Blob) Info() AssetInfo
- func (b *Blob) Open() (io.ReadSeekCloser, error)
- func (b *Blob) ReadAll() ([]byte, error)
- func (b *Blob) ReleaseResidentPages() error
- func (b *Blob) Size() int64
- func (b *Blob) Validate() error
- func (b *Blob) View() ([]byte, bool)
- type Catalog
- type ContentID
- type Manager
- func (m *Manager) Catalog() Catalog
- func (m *Manager) Close() error
- func (m *Manager) Load(name string) error
- func (m *Manager) LoadContext(ctx context.Context, name string) error
- func (m *Manager) LoadRequired() error
- func (m *Manager) LoadRequiredContext(ctx context.Context) error
- func (m *Manager) Loaded(name string) bool
- func (m *Manager) MountBytes(name string, data []byte) error
- func (m *Manager) MountBytesContext(ctx context.Context, name string, data []byte) error
- func (m *Manager) Open(name string) (fs.File, error)
- func (m *Manager) OpenBlob(name string) (*Blob, error)
- func (m *Manager) ReadDir(name string) ([]fs.DirEntry, error)
- func (m *Manager) ReadFile(name string) ([]byte, error)
- func (m *Manager) Stat(name string) (fs.FileInfo, error)
- func (m *Manager) Statistics() ManagerStatistics
- func (m *Manager) Unload(name string) error
- type ManagerStatistics
- type PackInput
- type PackProgress
- type PackResult
- type PackStats
- type PackageInfo
- type PackageLoader
- type PackageNotLoadedError
- type PackageSource
- type Preparation
- type PreparationState
- type Reader
- func (r *Reader) Close() error
- func (r *Reader) Open(name string) (iofs.File, error)
- func (r *Reader) OpenBlob(name string) (*Blob, error)
- func (r *Reader) ReadDir(name string) ([]iofs.DirEntry, error)
- func (r *Reader) ReadFile(name string) ([]byte, error)
- func (r *Reader) Stat(name string) (iofs.FileInfo, error)
Constants ¶
const ( CatalogFile = "catalog.bin" CatalogVersion = 2 BasePackage = "base" ContentIDSize = 16 )
const ( Extension = ".dat" FormatVersion = 5 )
Variables ¶
Functions ¶
func LoadDefaultPackage ¶
func MarshalCatalog ¶
MarshalCatalog encodes a validated catalog into Onix's compact binary format.
func MountDefaultPackage ¶
func OpenDirectory ¶
OpenDirectory returns the filesystem rooted at root. It matches os.DirFS for every fs.FS operation and additionally serves OpenBlob.
func SetDefaultProject ¶
SetDefaultProject mounts project-relative packaged files at their source project root.
func Size ¶
Size returns an image's logical dimensions from the configured resource source without decoding its pixel data. The source is opened through the engine resource layer, so packaged and directory-backed projects behave the same way.
func Sub ¶
Sub returns the subtree of source rooted at dir without dropping OpenBlob. A source that serves mapped blobs keeps serving them, so packaged builds and authoring directories resolve resources through the same path.
func ValidPackageName ¶
Types ¶
type AssetInfo ¶
AssetInfo is the catalog-owned metadata for one logical resource. Assets in each package are strictly sorted by Path and line up with the package index.
type Blob ¶
type Blob struct {
// contains filtered or unexported fields
}
Blob is a pinned, immutable view of one encoded resource. Bytes may return a direct package view; callers must not mutate it. Close releases the package pin and invalidates all views obtained from the Blob.
func NewMemoryBlob ¶
NewMemoryBlob takes ownership of data and returns an already verified Blob.
func (*Blob) ReadAll ¶
ReadAll returns an owned copy of the resource. Unlike Bytes, the result may be mutated and remains valid after Close.
func (*Blob) ReleaseResidentPages ¶
ReleaseResidentPages lets a mapped package discard fully covered file pages after a resource has been decoded. The bytes remain available on next access.
func (*Blob) View ¶
View returns the resource bytes without copying when the backing store can expose them directly. Callers must not mutate the result and must keep the Blob open for as long as they use it. The boolean reports whether a direct view exists; otherwise callers fall back to Bytes or ReadAll.
type Catalog ¶
type Catalog struct {
Packages []PackageInfo
Version int
}
func ParseCatalog ¶
ParseCatalog decodes an ONIXCAT2 resource catalog.
type ContentID ¶
type ContentID [ContentIDSize]byte
ContentID identifies identical encoded resource contents independently of their logical paths. It is the first 128 bits of SHA-256.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
func DefaultManager ¶
func NewManager ¶
func NewManager(catalog Catalog, loader PackageLoader) (*Manager, error)
func NewMemoryManager ¶
NewMemoryManager takes ownership of every package byte slice in packages. The slices must not be mutated for the lifetime of the Manager.
func OpenManager ¶
func (*Manager) LoadRequired ¶
func (*Manager) LoadRequiredContext ¶
func (*Manager) MountBytes ¶
MountBytes takes ownership of data and mounts it without copying. The caller must not mutate data after this method is called.
func (*Manager) MountBytesContext ¶
func (*Manager) Statistics ¶
func (m *Manager) Statistics() ManagerStatistics
type ManagerStatistics ¶
type PackInput ¶
PackInput names either an in-memory blob or a file-backed blob. Source is empty for in-memory data. Callers retain ownership until Pack returns.
func BytesInput ¶
type PackProgress ¶
PackProgress reports actual input inspection and writing work. Completed and Total include both passes, including deduplicated files. Active identifies the event before a potentially long operation; it clears on completion.
type PackResult ¶
func Pack ¶
func Pack(writer io.Writer, inputs []PackInput) (PackResult, error)
Pack writes the current indexed package format. It hashes file-backed inputs in a first pass, then streams only canonical blobs into the package.
func PackWithProgress ¶
func PackWithProgress(writer io.Writer, inputs []PackInput, progress func(PackProgress)) (PackResult, error)
PackWithProgress writes a package and reports each resource before and after its work, without retaining its contents or adding another input traversal.
type PackStats ¶
type PackStats struct {
Files int
RawBytes int64
PackedBytes int64
Stored int
Deduplicated int
DeduplicatedBytes int64
}
PackStats describes the uncompressed resource blobs written to a package. Stored counts non-alias entries; aliases are counted in Deduplicated.
type PackageInfo ¶
type PackageLoader ¶
type PackageLoader func(context.Context, PackageInfo) (PackageSource, error)
PackageLoader opens one package. It runs without the Manager mutex held and must honor cancellation whenever its backing transport supports it.
type PackageNotLoadedError ¶
func (*PackageNotLoadedError) Error ¶
func (e *PackageNotLoadedError) Error() string
func (*PackageNotLoadedError) Unwrap ¶
func (e *PackageNotLoadedError) Unwrap() error
type Preparation ¶
type Preparation[T any] struct { // contains filtered or unexported fields }
Preparation transfers one CPU result to its caller. Load must not access ECS or render devices. Wake may be called by the worker and must be thread-safe.
func BeginPreparation ¶
func BeginPreparation[T any](load func(context.Context) (T, error), discard func(T), wake func()) *Preparation[T]
func (*Preparation[T]) Cancel ¶
func (p *Preparation[T]) Cancel()
Cancel does not wait for I/O. An unpublished CPU result is released by its owner; results already transferred by Take must be released by the caller.
func (*Preparation[T]) Finish ¶
func (p *Preparation[T]) Finish(err error)
Finish records the render-thread outcome after Take.
func (*Preparation[T]) State ¶
func (p *Preparation[T]) State() PreparationState
func (*Preparation[T]) Take ¶
func (p *Preparation[T]) Take() (T, bool, error)
Take transfers the CPU result once, without waiting for unfinished work. The caller owns its cleanup and all subsequent GPU operations.
type PreparationState ¶
type PreparationState uint8
PreparationState separates background CPU work from render-thread upload.
const ( PreparingCPU PreparationState = iota CPUReady PreparingGPU PreparationReady PreparationFailed PreparationCancelled )