Skip to main content

AssetDecl

Struct AssetDecl 

Source
pub struct AssetDecl {
    pub path: String,
    pub hash: Option<String>,
    pub bytes: Option<u64>,
}
Expand description

One assets: entry: a file this component needs present on disk at run time — a themed template, a stylesheet, a whole scaffold tree — that is never read into the IR.

This is the deliberate counterpart to SlotDecl: a slot variant’s content is prompt text, so it belongs in the IR; an asset’s content is arbitrary (often binary, sometimes dozens of files) and is only ever needed on disk at dispatch time, so the IR carries just enough to identify and verify it — the path plus a content hash and size — never the bytes themselves. How an asset actually lands on disk (copied, symlinked, baked into an image) is a target decision that this declaration does not make.

hash and bytes are never authored: core is sans-IO, so the host reads the file, computes them, and fills them in before the declaration reaches crate::compile. They exist here (rather than being threaded through as a separate parameter, the way slot-variant content is) because — unlike a slot variant — nothing about compiling an asset needs core to see the file’s content, only its identity.

Fields§

§path: String

A file reference, resolved by the same rule as prompt_ref (relative to the directory that owns the declaration, no escaping it, must exist).

§hash: Option<String>

The asset’s content identity as sha256:<hex>. Populated by the host after it resolves and reads path, before compile.

Not authorable. skip keeps it out of deserialization entirely, so together with this struct’s deny_unknown_fields a hash: written in component.yml is a loud parse failure rather than a value silently replaced by the computed one. An author-written hash could only ever rot: it is a claim about file content that nothing keeps true, and accepting one would mean the IR sometimes carries a fingerprint that does not match the file it names.

§bytes: Option<u64>

The asset’s size in bytes. Populated alongside hash, and not authorable for the same reason.

Trait Implementations§

Source§

impl Clone for AssetDecl

Source§

fn clone(&self) -> Self

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 Debug for AssetDecl

Source§

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

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

impl<'de> Deserialize<'de> for AssetDecl

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more

Auto Trait Implementations§

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.