Skip to main content

RenderedFile

Struct RenderedFile 

Source
pub struct RenderedFile {
    pub path: PathBuf,
    pub contents: String,
}
Expand description

One rendered artifact — a (path, contents) pair every per-target caixa-<target> renderer emits at every leaf of its output tree. Carries the sandboxed relative path the substrate writes the artifact under (relative to the renderer-chosen output root — the per-chart directory for caixa-helm’s lareira-<nome> chart tree, the per-caixa ./clusters/<cluster>/services/<nome>/ sub-tree for caixa-flux’s cluster_bundle Flux v2 CR trio) alongside the pre-serialized byte contents the substrate writes to it.

Lifted from two identical-shape per-renderer arms in caixa-flux (BundleFile { path: PathBuf, contents: String }) and caixa-helm (ChartFile { path: PathBuf, contents: String }) — same field pair, same derives (`Debug + Clone

  • PartialEq + Eq), no per-type impls — carrying the same "one rendered leaf artifact" contract twice. Every prior per-target renderer had reinvented the same two-field record because there was no substrate-side canonical (path, contents) shape to reach for; the future per-target renderers the M4/M5 roadmap acknowledges (caixa-otel's per-collector-config emit, the future per-Aplicacao mesh.pleme.io/v1alpha1/AplicacaoCR materializer's per-CR YAML emit, the future per-Supervisor reconciler renderer's per-child bundle emit) would have re-added a third and fourth clone of the same record — exactly the "render-side patterns recurring ≥2 times acrosscaixa-helm/caixa-flux/caixa-mesh` become helpers. Duplication is a bug. (PRIME DIRECTIVE.)“ compounding-mandate slot item.

Both prior arms remain as public pub type BundleFile = caixa_core::RenderedFile; / pub type ChartFile = caixa_core::RenderedFile; aliases at their crate boundary so every existing struct-literal construction site (BundleFile { path: …, contents: … } / ChartFile { path: …, contents: … }), every field-access site (.path / .contents), and every derive-fed navigator (== equality pins, Debug formatting probes) resolves through the type alias to the canonical RenderedFile with no per-call-site edit — Rust type aliases carry the same #[derive]-generated Debug/Clone/PartialEq/ Eq impls as their canonical, so the shared-shape contract lives at one type definition instead of two verbatim clones drifting silently on any future rebrand.

Peer to the KindMismatch / ServicoCountMismatch typed-view lifts on the sibling per-renderer-error-diagnostic-shape axis: both families lift a per-renderer duplicated record onto a canonical substrate-side type, so a future per-target renderer joins the pattern by re-exporting one alias instead of open-coding another clone.

The path axis carries the sandboxed relative path — the same is_sandboxed_relative_path discipline the Caixa::validate_code_paths invariant enforces at the manifest-side path axis. No renderer today runs the predicate against the emit-side per-RenderedFile.path — the paths are picked from substrate-canonical &'static str filename constants (FLUX_GITREPOSITORY_YAML_FILENAME, FLUX_HELMRELEASE_YAML_FILENAME, FLUX_KUSTOMIZATION_YAML_FILENAME, HELM_CHART_YAML_FILENAME, HELM_VALUES_YAML_FILENAME) rather than author input, so a per-emit-time sandbox check would be belt-and-suspenders — but the shared type shape makes a future sandbox-at-emit-time invariant a one-place add across every per-target renderer.

Fields§

§path: PathBuf

Sandboxed relative path the substrate writes the artifact under (relative to the renderer-chosen output root). Substrate-canonical filename constants (FLUX_GITREPOSITORY_YAML_FILENAME / FLUX_HELMRELEASE_YAML_FILENAME / FLUX_KUSTOMIZATION_YAML_FILENAME for the caixa-flux [cluster_bundle] Flux v2 CR trio, HELM_CHART_YAML_FILENAME / HELM_VALUES_YAML_FILENAME for the caixa-helm lareira-<nome> chart directory) source every path today.

§contents: String

The rendered byte contents — a pre-serialized UTF-8 body every downstream writer (caixa-flux::cluster_bundle’s per-GitRepository/HelmRelease/Kustomization YAML emit, caixa-helm::render_chart_for_servico’s per-Chart.yaml/ values.yaml/README.md chart-directory emit) hands to std::fs::write verbatim under the paired Self::path.

Implementations§

Source§

impl RenderedFile

Source

pub fn new<P, S>(path: P, contents: S) -> Self
where P: Into<PathBuf>, S: Into<String>,

Construct a RenderedFile from its two axes — the sandboxed relative path the substrate writes the artifact under and the pre-serialized UTF-8 contents the paired std::fs::write hands to that path. Accepts anything convertible into a PathBuf (&'static str from the substrate-canonical filename constants HELM_CHART_YAML_FILENAME / HELM_VALUES_YAML_FILENAME / FLUX_GITREPOSITORY_YAML_FILENAME / FLUX_HELMRELEASE_YAML_FILENAME / FLUX_KUSTOMIZATION_YAML_FILENAME every current per-target renderer picks its per-artifact leaf path from, String / PathBuf for future author-supplied paths) and anything convertible into String (the serde_yaml::to_string / format! outputs every current renderer already threads into the paired contents field).

Lifted from six identical-shape struct-literal construction sites — three per-artifact leaves in caixa-helm’s render_chart_for_servico_with (Chart.yaml, values.yaml, README.md) and three per-CR leaves in caixa-flux’s cluster_bundle (gitrepository.yaml, helmrelease.yaml, kustomization.yaml) — each of which open-coded a four-line <Xxx>File { path: PathBuf::from(FILENAME_CONST), contents: <body> } block that re-derived the same PathBuf::from(&str) wrap + the same two-field assembly. Every existing struct- literal construction (the type-alias identity pins at [caixa_flux::tests::bundle_file_alias_resolves_to_caixa_core_rendered_file] / [caixa_helm::tests::chart_file_alias_resolves_to_caixa_core_rendered_file], the substrate-side field-shape pins in this crate’s test module) continues to compile — RenderedFile::new is an additive inherent constructor that leaves the pub path / pub contents field visibility untouched, so a future rebrand on the record shape (a per-artifact hash / provenance field addition, a per-artifact write-mode discriminator once per-cluster-writer sandboxing lands) still reaches every per-target renderer through this canonical constructor + the existing struct-literal pinning by construction. Peer to the sibling substrate-side canonical-composer surface (oci_chart_ref / cilium_network_policy_name / gateway_api_http_route_name / lareira_chart_name) — each is a canonical &'static fn(&str, …) -> String composer that every per-target renderer routes through instead of re-deriving the same encoding inline.

A future per-target renderer (caixa-otel’s per-collector- config emit, the future mesh.pleme.io/v1alpha1/Aplicacao CR materializer’s per-CR YAML emit, the future per-Supervisor reconciler renderer’s per-child bundle emit) that constructs a RenderedFile now reaches for RenderedFile::new and participates in the same substrate-side per-artifact- construction contract, so any addition here (say, a sandboxed_relative_path invariant check on path at construction time, the is_sandboxed_relative_path discipline the docstring above acknowledges is not yet run at emit time) reaches every per-target renderer through one caixa-core edit instead of a coordinated six-site rewrite.

Trait Implementations§

Source§

impl Clone for RenderedFile

Source§

fn clone(&self) -> RenderedFile

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 RenderedFile

Source§

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

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

impl Eq for RenderedFile

Source§

impl PartialEq for RenderedFile

Source§

fn eq(&self, other: &RenderedFile) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for RenderedFile

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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.