pub struct DecodeCx<'a> {
pub limits: Limits,
pub bundle: Option<&'a Bundle>,
}Expand description
What a format has besides the file it decodes: the limits, and the bundle the file is in, for the files it names (a sidecar’s picture, a manifest’s sounds). Without a bundle, every file named is missing.
Fields§
§limits: LimitsThe limits of this decoding.
bundle: Option<&'a Bundle>The bundle the file is in, if any.
Implementations§
Source§impl<'a> DecodeCx<'a>
impl<'a> DecodeCx<'a>
Sourcepub const fn with_limits(self, limits: Limits) -> Self
pub const fn with_limits(self, limits: Limits) -> Self
This context, with limits.
Sourcepub fn has(&self, path: &str) -> bool
pub fn has(&self, path: &str) -> bool
Whether the bundle has the file at path (Bundle::has).
Sourcepub fn bytes(&self, path: &str) -> Option<&'static [u8]>
pub fn bytes(&self, path: &str) -> Option<&'static [u8]>
The bytes of the file at path (relative to a layer’s root), if the
bundle has it.
Sourcepub fn text(&self, path: &str) -> Option<&'static str>
pub fn text(&self, path: &str) -> Option<&'static str>
The text of the file at path, if the bundle has it and it is valid
UTF-8.
Sourcepub fn left_out(&self, path: &str) -> bool
pub fn left_out(&self, path: &str) -> bool
Whether the bundle leaves the file at path out on purpose
(Bundle::left_out).
Sourcepub fn files_under(&self, dir: &str) -> Vec<&'static str>
pub fn files_under(&self, dir: &str) -> Vec<&'static str>
The paths of the files inside directory dir or below it
(Bundle::files_under); none without a bundle.
Sourcepub fn import_settings<S: ImportSettings>(
&self,
file: &AssetPath,
) -> Result<S, Vec<ContentError>>
pub fn import_settings<S: ImportSettings>( &self, file: &AssetPath, ) -> Result<S, Vec<ContentError>>
The import settings S of file (ADR-0057): its section in the
nearest settings file of settings_chain that has one (the file’s
own .meta, then each folder’s _folder.meta up to the root),
whole; S::default() without a bundle or when none has it. Each
file looked for is read with bytes, so the
watcher hears of it, found or not. A
settings file on the way that doesn’t read is an error, even when a
farther one has the section.