[−][src]Struct screen_13::pak::Pak
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]
R: Read + Seek,
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]
&self,
key: K,
locale: L
) -> Cow<'_, str>
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]
R: RefUnwindSafe,
impl<R> Send for Pak<R> where
R: Send, [src]
R: Send,
impl<R> Sync for Pak<R> where
R: Sync, [src]
R: Sync,
impl<R> Unpin for Pak<R> where
R: Unpin, [src]
R: Unpin,
impl<R> UnwindSafe for Pak<R> where
R: UnwindSafe, [src]
R: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> Pointable for T
pub const ALIGN: usize
type Init = T
The type for initializers.
pub unsafe fn init(init: <T as Pointable>::Init) -> usize
pub unsafe fn deref<'a>(ptr: usize) -> &'a T
pub unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T
pub unsafe fn drop(ptr: usize)
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]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,