pub trait Source {
// Required methods
fn get_uri(&self) -> &str;
fn has_package(&self, package_name: &str) -> bool;
fn list_packages(&mut self) -> Vec<String>;
fn read_file<'a>(
&'a mut self,
package_name: &str,
pathname: &str,
) -> Result<Box<dyn ReadSeek + 'a>, PackageError>;
fn iter_entries<'a>(
&'a mut self,
package_name: &str,
type_folder: &str,
) -> Box<dyn Iterator<Item = Result<String, PackageError>> + 'a>;
fn trust_level(&self, package_name: &str) -> TrustLevel;
// Provided method
fn write_file<'a>(
&'a mut self,
package_name: &str,
pathname: &str,
) -> Result<Box<dyn Write + 'a>, PackageError> { ... }
}
Expand description
Represents a location that packages can be loaded from. For example, you could load packages from the filesystem (via FilesystemSource, or out of a special archive format.
Required Methods§
Sourcefn get_uri(&self) -> &str
fn get_uri(&self) -> &str
The path that this Source originates from. Only used for debug purposes.
Sourcefn has_package(&self, package_name: &str) -> bool
fn has_package(&self, package_name: &str) -> bool
Returns true if the Source has a package of the given name, otherwise returns false
Sourcefn list_packages(&mut self) -> Vec<String>
fn list_packages(&mut self) -> Vec<String>
Returns a list of all packages available in this Source. Do not call this repeatedly!
Sourcefn read_file<'a>(
&'a mut self,
package_name: &str,
pathname: &str,
) -> Result<Box<dyn ReadSeek + 'a>, PackageError>
fn read_file<'a>( &'a mut self, package_name: &str, pathname: &str, ) -> Result<Box<dyn ReadSeek + 'a>, PackageError>
Sourcefn iter_entries<'a>(
&'a mut self,
package_name: &str,
type_folder: &str,
) -> Box<dyn Iterator<Item = Result<String, PackageError>> + 'a>
fn iter_entries<'a>( &'a mut self, package_name: &str, type_folder: &str, ) -> Box<dyn Iterator<Item = Result<String, PackageError>> + 'a>
Returns an iterator through the items in a given package, if the Source has said package
Sourcefn trust_level(&self, package_name: &str) -> TrustLevel
fn trust_level(&self, package_name: &str) -> TrustLevel
Returns the source’s trust level for the given package. Trusted sources are able to load resource types marked as requiring trust.
Provided Methods§
Sourcefn write_file<'a>(
&'a mut self,
package_name: &str,
pathname: &str,
) -> Result<Box<dyn Write + 'a>, PackageError>
fn write_file<'a>( &'a mut self, package_name: &str, pathname: &str, ) -> Result<Box<dyn Write + 'a>, PackageError>
Returns a Write for the file at the given pathname.