Struct respk::Package [−][src]
pub struct Package { /* fields omitted */ }
Provides read and write access to resources in a respk package file.
Methods
impl Package
[src]
impl Package
pub fn open<P: AsRef<Path>>(path: P) -> Result<Package, Error>
[src]
pub fn open<P: AsRef<Path>>(path: P) -> Result<Package, Error>
Open a package from a file.
If the file does not exist, it will be created.
pub fn len(&self) -> u64
[src]
pub fn len(&self) -> u64
Get the number of files in the package.
pub fn resources(&self) -> Result<Vec<ResourceInfo>, Error>
[src]
pub fn resources(&self) -> Result<Vec<ResourceInfo>, Error>
Get a list of resources in the package.
pub fn get_info<S: AsRef<str>>(&self, path: S) -> Result<ResourceInfo, Error>
[src]
pub fn get_info<S: AsRef<str>>(&self, path: S) -> Result<ResourceInfo, Error>
Get a resource by name.
pub fn read<S: AsRef<str>>(&self, path: S) -> Result<Resource, Error>
[src]
pub fn read<S: AsRef<str>>(&self, path: S) -> Result<Resource, Error>
Read the contents of a resource file.
pub fn stream<S: AsRef<str>>(&self, path: S) -> Result<ResourceReader, Error>
[src]
pub fn stream<S: AsRef<str>>(&self, path: S) -> Result<ResourceReader, Error>
Open a resource for reading.
This method allows you to stream a resource from disk and process the resource incrementally instead of waiting
for the entire resource file to be read into memory. If you are able to use a streamed resource, this method is
usually preferred over read()
.
pub fn write<S, R>(&self, path: S, contents: R) -> Result<(), Error> where
S: AsRef<str>,
R: Read,
[src]
pub fn write<S, R>(&self, path: S, contents: R) -> Result<(), Error> where
S: AsRef<str>,
R: Read,
Write the given data stream to a resource path.
pub fn delete<S>(&self, path: S) -> Result<(), Error> where
S: AsRef<str>,
[src]
pub fn delete<S>(&self, path: S) -> Result<(), Error> where
S: AsRef<str>,
Delete a resource from the package.