[][src]Struct screen_13::pak::Pak

pub struct Pak<R> where
    R: Read + Seek
{ /* fields omitted */ }

A wrapper type which allows callers to specify the Read and Seek implementations used to read assets.

Programs may specify their own implementations with a type definition. For a buffered file which handles content re-reads better on systems with enough memory:

type PakFile = Pak<BufReader<File>>;

Or for a basic implementation, one which would be compatible with the ECS sample code which contains bespoke data buffering:

type PakFile = Pak<File>;

Most programs will want to use the provided open(...) function of Pak<BufReader<File>>, which provides a buffered file-based .pak asset reader.

Examples

use {screen_13::prelude_all::*, std::io::Error};

fn main() -> Result<(), Error> {
    // This buffers the file so we don't have to re-read the data from disk if the asset is
    // re-read. TODO: work on an option for people who don't want buffered IO. 🚧
    let pak = Pak::open("/home/john/Desktop/foo.pak")?;
    ...
}

Implementations

impl Pak<BufReader<File>>[src]

pub fn open<P: AsRef<Path>>(path: P) -> Result<Self, Error>[src]

Opens the given path and decodes a Pak.

impl<R> Pak<R> where
    R: Read + Seek
[src]

pub fn animation_id<K: AsRef<str>>(&self, key: K) -> Option<AnimationId>[src]

Gets the pak-unique AnimationId corresponding to the given key, if one exsits.

pub fn bitmap_id<K: AsRef<str>>(&self, key: K) -> Option<BitmapId>[src]

Gets the pak-unique BitmapId corresponding to the given key, if one exsits.

pub fn bitmap_font_id<K: AsRef<str>>(&self, key: K) -> Option<BitmapFontId>[src]

Gets the pak-unique BitmapFontId corresponding to the given key, if one exsits.

pub fn blob_id<K: AsRef<str>>(&self, key: K) -> Option<BlobId>[src]

Gets the pak-unique BlobId corresponding to the given key, if one exsits.

pub fn material_id<K: AsRef<str>>(&self, key: K) -> Option<MaterialId>[src]

Gets the pak-unique MaterialId corresponding to the given key, if one exsits.

pub fn material<K: AsRef<str>>(&self, key: K) -> Material[src]

Gets the material for the given key.

pub fn material_with_id(&self, id: MaterialId) -> Material[src]

Gets the material with the given id.

pub fn model_id<K: AsRef<str>>(&self, key: K) -> Option<ModelId>[src]

Gets the pak-unique ModelId corresponding to the given key, if one exsits.

pub fn scene_id<K: AsRef<str>>(&self, key: K) -> Option<SceneId>[src]

Gets the pak-unique SceneId corresponding to the given key, if one exsits.

pub fn text<K: AsRef<str>>(&self, key: K) -> Cow<'_, str>[src]

Gets the text corresponding to the given key. Panics if the key doesn't exist.

pub fn text_id<K: AsRef<str>>(&self, key: K) -> Option<TextId>[src]

Gets the pak-unique TextId corresponding to the given key, if one exsits.

pub fn text_locale<K: AsRef<str>, L: AsRef<str>>(
    &self,
    key: K,
    locale: L
) -> Cow<'_, str>
[src]

Gets the localized text corresponding to the given key and locale. Panics if the key doesn't exist.

pub fn text_raw<K: AsRef<str>>(&self, key: K) -> Cow<'_, str>[src]

Gets the text corresponding to the given key. Panics if the key doesn't exist.

pub fn read_blob(&mut self, id: BlobId) -> Vec<u8>[src]

Reads the corresponding blob for the given id.

pub fn read_scene(&mut self, id: SceneId) -> Scene[src]

Reads the corresponding scene for the given id.

Auto Trait Implementations

impl<R> RefUnwindSafe for Pak<R> where
    R: RefUnwindSafe
[src]

impl<R> Send for Pak<R> where
    R: Send
[src]

impl<R> Sync for Pak<R> where
    R: Sync
[src]

impl<R> Unpin for Pak<R> where
    R: Unpin
[src]

impl<R> UnwindSafe for Pak<R> where
    R: UnwindSafe
[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Pointable for T

type Init = T

The type for initializers.

impl<T> Same<T> for T[src]

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.