Skip to main content

ResourceKind

Trait ResourceKind 

Source
pub trait ResourceKind: Sized {
    // Required methods
    fn borrow_from(resource: &Resource) -> Option<&Self>;
    fn take_from(resource: Resource) -> Option<Self>;
    fn into_resource(self) -> Resource;
}
Expand description

A kind of resource that can live in a ResourceGraph, and the resource an id of that kind resolves to.

Implemented for the wgpu handles the graph stores and for Virtual, the kind that holds no handle. The implementor is not just a tag: it is the payload ResourceGraph::get hands out, so the kind and the resource read as one thing — a ResHandle<wgpu::Buffer> names a buffer, not a mark saying “buffer”.

Resource itself implements the trait as the erased kind: the one that names a resource whose kind is known only at runtime.

Required Methods§

Source

fn borrow_from(resource: &Resource) -> Option<&Self>

Borrow this kind out of a stored Resource, or None when that resource is of another kind.

Source

fn take_from(resource: Resource) -> Option<Self>

Take this kind out of a stored Resource, or None when that resource is of another kind.

Source

fn into_resource(self) -> Resource

This value as a stored Resource.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl ResourceKind for BindGroup

Source§

fn borrow_from(resource: &Resource) -> Option<&Self>

Source§

fn take_from(resource: Resource) -> Option<Self>

Source§

fn into_resource(self) -> Resource

Source§

impl ResourceKind for Buffer

Source§

fn borrow_from(resource: &Resource) -> Option<&Self>

Source§

fn take_from(resource: Resource) -> Option<Self>

Source§

fn into_resource(self) -> Resource

Source§

impl ResourceKind for Sampler

Source§

fn borrow_from(resource: &Resource) -> Option<&Self>

Source§

fn take_from(resource: Resource) -> Option<Self>

Source§

fn into_resource(self) -> Resource

Source§

impl ResourceKind for Texture

Source§

fn borrow_from(resource: &Resource) -> Option<&Self>

Source§

fn take_from(resource: Resource) -> Option<Self>

Source§

fn into_resource(self) -> Resource

Implementors§