# Resource handles

> The RAII half, written once for every handle type.

Source: https://omardev29.github.io/rmp-docs/reference/classes/rmp-detail-Resource.html

class `#include <rmp/assets.h>` [include/rmp/assets.h:125](https://github.com/omardev29/raylib_multiplatform/blob/982bf2a1e307c49776bff84211260703b8de6895/include/rmp/assets.h#L125-L220)

The RAII half, written once for every handle type. Copy shares, move steals, and the last handle to a resource going away is what unloads it.

### `Resource`

explicit Resource(Slot *slot)

function [include/rmp/assets.h:131](https://github.com/omardev29/raylib_multiplatform/blob/982bf2a1e307c49776bff84211260703b8de6895/include/rmp/assets.h#L131)

An empty handle: `valid()` is false until a loader's result is assigned to it. The Slot constructor is how the loaders in [`rmp::assets`](https://omardev29.github.io/rmp-docs/reference/namespaces/rmp-assets.html) make a full one, from a reference the resource table has already counted.

### `valid`, `operator bool`

bool valid() const

explicit operator bool() const

function [include/rmp/assets.h:157](https://github.com/omardev29/raylib_multiplatform/blob/982bf2a1e307c49776bff84211260703b8de6895/include/rmp/assets.h#L157)

True when this handle holds a resource. False for one that failed to load, was never assigned, or was moved from; `if (texture)` asks the same.

### `name`

std::string_view name() const

function [include/rmp/assets.h:162](https://github.com/omardev29/raylib_multiplatform/blob/982bf2a1e307c49776bff84211260703b8de6895/include/rmp/assets.h#L162-L164)

The name it was loaded under — "ui.ttf", "player.aseprite" — or "" for an empty handle. Valid while this handle holds it.

### `changed`, `reload`

bool changed() const requires(K == ResourceKind::TEXTURE)

bool reload() requires(K == ResourceKind::TEXTURE)

function [include/rmp/assets.h:177](https://github.com/omardev29/raylib_multiplatform/blob/982bf2a1e307c49776bff84211260703b8de6895/include/rmp/assets.h#L177-L181)

A texture loaded from a file in resources/ remembers it: `changed()` is true once the file differs from what the texture holds — the sprite redrawn and saved while the game runs — and `reload()` loads it again in place, so every handle to it draws the new picture:

```cpp
if (rabbit.changed()) rabbit.reload();
```

Debug builds on the desktop only, like [`rmp::Value::changed()`](https://omardev29.github.io/rmp-docs/reference/classes/rmp-Value.html#changed); elsewhere, and for an empty handle, `changed()` is false and `reload()` does nothing. `changed()` compares two numbers: ask it every frame. `reload()` is false, and the texture as it was, when the file does not decode now.

### `raw`

const T &raw() const

function [include/rmp/assets.h:191](https://github.com/omardev29/raylib_multiplatform/blob/982bf2a1e307c49776bff84211260703b8de6895/include/rmp/assets.h#L191-L195)

An empty resource yields a zeroed raylib struct rather than a crash. raylib draws nothing for one of those, which is the behaviour a missing asset should have: a hole in the picture, not a dead process.

### `operator const T &`

operator const T &() const &

function [include/rmp/assets.h:205](https://github.com/omardev29/raylib_multiplatform/blob/982bf2a1e307c49776bff84211260703b8de6895/include/rmp/assets.h#L205)

Only an LVALUE converts. `DrawTexture(rabbit, ...)` compiles; `Texture2D t = load_texture("x.png");` does NOT, and that is the point — it converted, the temporary handle died on the same line, and `t` was a texture that had already been unloaded. The README and four examples had it, and so did the UI's own font. The deleted `&&` overload is what refuses the temporary: a `const &`-qualified function on its own would still accept one, because a const reference binds to an rvalue.
