pub trait Asset:
Read
+ Seek
+ Send {
// Required method
fn size(&self) -> Result<u64>;
// Provided methods
fn read_all(&mut self) -> Result<Vec<u8>> { ... }
fn shared_buffer(&self) -> Option<SharedBuffer> { ... }
fn into_buffer(self: Box<Self>) -> Result<AssetBuffer> { ... }
}Expand description
Readable asset handle returned by Resolver::open_asset.
This trait abstracts over the underlying storage mechanism (filesystem, in-memory buffer, archive entry, etc.) and provides random-access reading.
Required Methods§
Provided Methods§
Sourcefn into_buffer(self: Box<Self>) -> Result<AssetBuffer>
fn into_buffer(self: Box<Self>) -> Result<AssetBuffer>
The complete asset as a buffer, consuming the asset: the view
shared_buffer returns when it returns one,
otherwise what read_all reads. An asset that owns
its buffer hands it over.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementations on Foreign Types§
Source§impl Asset for Cursor<AssetBuffer>
An asset over a buffer already in hand, as a package entry, a mapped file
or the bytes a host keeps in memory are served.
impl Asset for Cursor<AssetBuffer>
An asset over a buffer already in hand, as a package entry, a mapped file or the bytes a host keeps in memory are served.