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]
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.
fn len(&self) -> u64
Get the number of files in the package.
fn resources(&self) -> Result<Vec<ResourceInfo>, Error>
Get a list of resources in the package.
fn get_info<S: AsRef<str>>(&self, path: S) -> Result<ResourceInfo, Error>
Get a resource by name.
fn read<S: AsRef<str>>(&self, path: S) -> Result<Resource, Error>
Read the contents of a resource file.
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()
.
fn write<S, R>(&self, path: S, contents: R) -> Result<(), Error> where
S: AsRef<str>,
R: Read,
S: AsRef<str>,
R: Read,
Write the given data stream to a resource path.
fn delete<S>(&self, path: S) -> Result<(), Error> where
S: AsRef<str>,
S: AsRef<str>,
Delete a resource from the package.