Skip to main content

DecodeCx

Struct DecodeCx 

Source
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: Limits

The limits of this decoding.

§bundle: Option<&'a Bundle>

The bundle the file is in, if any.

Implementations§

Source§

impl<'a> DecodeCx<'a>

Source

pub const fn new() -> Self

No bundle, no limits but the formats’ own: for bytes decoded alone.

Source

pub const fn in_bundle(bundle: &'a Bundle) -> Self

Decoding a file of bundle.

Source

pub const fn with_limits(self, limits: Limits) -> Self

This context, with limits.

Source

pub fn has(&self, path: &str) -> bool

Whether the bundle has the file at path (Bundle::has).

Source

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.

Source

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.

Source

pub fn shown(&self, path: &str) -> String

The name errors show the file at path by.

Source

pub fn left_out(&self, path: &str) -> bool

Whether the bundle leaves the file at path out on purpose (Bundle::left_out).

Source

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.

Source

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.

Trait Implementations§

Source§

impl<'a> Clone for DecodeCx<'a>

Source§

fn clone(&self) -> DecodeCx<'a>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Copy for DecodeCx<'a>

Source§

impl<'a> Debug for DecodeCx<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> Default for DecodeCx<'a>

Source§

fn default() -> DecodeCx<'a>

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for DecodeCx<'a>

§

impl<'a> RefUnwindSafe for DecodeCx<'a>

§

impl<'a> Send for DecodeCx<'a>

§

impl<'a> Sync for DecodeCx<'a>

§

impl<'a> Unpin for DecodeCx<'a>

§

impl<'a> UnsafeUnpin for DecodeCx<'a>

§

impl<'a> UnwindSafe for DecodeCx<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.