Module rafx_base::resource_map

source ·
Expand description

Allows placing resources (i.e. “global” data) in a dictionary and looking it up by type. The data could be “global” systems, component storages, component factories, etc.

This implements a type system for expressing read/write dependencies. Many readers and single writers are allowed, but not both at the same time. This is checked at runtime, not compile time.

Lots of inspiration taken from shred for how to create a type system to express read/write dependencies

Structs§

  • This type represents requesting read access to T. If T is not registered, trying to fill this request will be fatal
  • Represents a filled read-only request for T
  • Every type can be converted to a ResourceId. The ResourceId is used to look up the type’s value in the ResourceMap
  • A key-value structure. The key is a type, and the value is a single object of that type
  • Builder for creating a ResourceMap
  • This type represents requesting write access to T. If T is not registered, trying to fill this request will be fatal
  • Represents a filled read/write request for T

Traits§

  • Borrow base trait. This base trait is required to allow inductively composing tuples of ReadBorrow/WriteBorrow i.e. (), (A), (A, B), (A, B, …) inductively
  • DataRequirement base trait, which underlies Read and Write requests
  • Any data that can be stored in the ResourceMap must implement this trait. There is a blanket implementation provided for all compatible types

Type Aliases§

  • Same as Read, but will return None rather than being fatal
  • Same as Write, but will return None rather than being fatal