Skip to main content

CaixaVersion

Struct CaixaVersion 

Source
pub struct CaixaVersion(pub String);
Expand description

A caixa’s pinned version — a thin typed wrapper over a String that parses as semver::Version on demand.

Stored as a String at rest so authoring a caixa.lisp stays a single quoted literal. The typed form is reached through Self::parse.

Tuple Fields§

§0: String

Implementations§

Source§

impl CaixaVersion

Source

pub fn parse(&self) -> Result<Version, VersionError>

Parse and validate the wrapped string as semver.

Source

pub const fn as_str(&self) -> &str

Borrow the string form.

Trait Implementations§

Source§

impl AsRef<str> for CaixaVersion

Substrate-canonical AsRef<str> projection on the CaixaVersion typed newtype — routes through the same CaixaVersion::as_str pub const fn scalar accessor the sibling fmt::Display impl and every downstream &str-shaped consumer already keys off, so any future consumer that binds a CaixaVersion through the standard-library impl AsRef<str> bound (a Path-shaped file- system reader on the operator side that accepts the version body as one segment of a per-caixa versao/<v>/... on-disk cache path, a builder-shaped API on the future feira publish writer verb that composes <prefix><versao> through a git-tag builder crate’s impl AsRef<str> join step, a HashMap<CaixaVersion, _> lookup through the map.get::<str>(v.as_ref()) shape a future version-keyed dispatch table lands on) reaches the wrapped String through one substrate-primitive dispatch rather than through the pre-lift .as_str() open-coded projection at every wire-up.

Peer of the sibling fmt::Display impl on the same primitive — both delegate to the shared CaixaVersion::as_str pub const fn accessor, so [format!("{v}")], v.as_str(), and <CaixaVersion as AsRef<str>>::as_ref(&v) resolve to the same byte-string per instance by construction. A future rebrand of the wrapped storage (a hypothetical widening to a typed semver::Version slot the roadmap acknowledges once eager parse-on-construct discipline lands, an internal normalization step that trims leading zeroes off pre-release identifiers, a per-cluster overlay the operator pins through a future :versao-overrides slot) that changes what CaixaVersion::as_str returns migrates every consumer of every one of the three paths in lockstep.

Same “route the trait impl through the substrate-primitive accessor” discipline the sibling fmt::Display impl on this type already carries — extends it onto the standard-library AsRef<str> projection axis every third-party API that takes impl AsRef<str> (the std::path::Path::new / std::fs interop surface, std::process::Command::arg, the peer tracing::field::Value recorder’s Str-arm, every clap-side value_parser! fold that accepts an owned newtype through impl AsRef<str>) already binds through. Rust-side newtype convention pairs AsRef<str> and fmt::Display on the same primitive so a caller who has one has both; before this lift, CaixaVersion carried fmt::Display but not the paired AsRef<str> impl the convention names.

The first standard-library trait added to CaixaVersion beyond the pre-existing serde::Serialize / serde::Deserialize / Debug / Clone / PartialEq / Eq / Hash derives and the paired fmt::Display / From<String> / From<&str> hand-written impls. Pinned load-bearing by [tests::caixa_version_as_ref_str_routes_through_as_str_accessor] (byte-parity pin against CaixaVersion::as_str) — any future silent detour that routes the impl through a divergent projection (a Cow<'_, str> intermediate, a stray .to_lowercase() normalization, a swap onto a per-arm inline &self.0.as_str() re-inlining) trips at caixa-core test time under assert_eq! rather than at a downstream impl AsRef<str>-bound consumer’s silent split.

Source§

fn as_ref(&self) -> &str

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Clone for CaixaVersion

Source§

fn clone(&self) -> CaixaVersion

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 CaixaVersion

Source§

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

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

impl<'de> Deserialize<'de> for CaixaVersion

Source§

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

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for CaixaVersion

Source§

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

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

impl Eq for CaixaVersion

Source§

impl From<&CaixaVersion> for String

Trait-idiomatic borrowed-input, owned-String output reverse projection on the CaixaVersion newtype primitive — the borrowed-input companion to the paired owned-input [From<CaixaVersion> for String] impl immediately above. Routes byte-for-byte through the substrate-primitive CaixaVersion::as_str pub const fn accessor (via str::to_owned) so every consumer that holds a borrowed [&CaixaVersion] and needs an owned String — a […].iter().map(String::from).collect::<Vec<_>>() per-instance materializer over &[CaixaVersion] (whose iterator yields &CaixaVersion, not CaixaVersion, so the owned-input [From<CaixaVersion> for String] axis alone forces every call site through an explicit .clone() / dereference restatement), a future HashMap::<String, _>::from_iter that keys off a borrowed- iteration axis where cloning the wrapper would allocate one String beyond the map entry’s own, a future serde_json::Value::String(String::from(&caixa.versao)) structured-payload composer that owns the emit-path without moving out of a borrowed field — reaches the wrapped byte-string through this one dispatch on the substrate primitive.

Second corner on the {Self, &Self} → String reverse-projection family opened on the paired owned-input [From<CaixaVersion> for String] impl immediately above. Rust’s From trait does not derive the From<&Self> sibling from a From<Self> impl (the blanket impl<T, U> From<&T> for U where T: Clone, U: From<T> does not exist in core), so every newtype that carries the owned-input reverse axis but not the borrowed-input axis forces every borrowed call site through a .clone() / <String>::from(v.clone()) detour whose type bounds have no compile-time link back to the newtype.

Pinned load-bearing by [tests::caixa_version_from_borrowed_into_owned_string_routes_through_as_str_accessor] (byte-parity pin against CaixaVersion::as_str via a borrowed input) and [tests::caixa_version_from_owned_and_borrowed_into_string_agree_on_every_shape] (cross-axis partition pin against the paired owned-input [From<CaixaVersion> for String] impl on the same instance, closing the “owned-input move vs. borrowed-input clone” bifurcation on the same wrapped body).

Source§

fn from(v: &CaixaVersion) -> String

Converts to this type from the input type.
Source§

impl From<&str> for CaixaVersion

Source§

fn from(s: &str) -> Self

Converts to this type from the input type.
Source§

impl From<CaixaVersion> for String

Trait-idiomatic owned-String reverse projection on the CaixaVersion newtype primitive — the owned-heap-string inverse of the pre-existing [From<String> for CaixaVersion] / [From<&str> for CaixaVersion] forward-projection pair on this primitive. Returns the wrapped String verbatim ([Self::0], a move of the pre-existing heap allocation — no re-copy of the per-instance version body’s bytes), so every consumer that binds a CaixaVersion through the standard-library .into() / [From<Self> for String] (equivalently Into<String>) axis reaches the wrapped byte-string through one substrate-primitive dispatch rather than through a .as_str().to_owned() / .to_string() allocating detour whose bounds have no compile-time link back to the newtype’s storage.

A future consumer that wants to unwrap a CaixaVersion into an owned String — a serde_json::Value::String(versao.into()) structured-payload composer where the Value::String arm typing demands an owned String and the sibling AsRef<str>-borrowed axis forces an explicit .to_owned() restatement at every call site, a future HashMap::<String, _>::from_iter([(versao.into(), _)]) per-versao lookup where the map’s key type is owned String rather than &str borrowed from a stashed CaixaVersion, a future Cow::<'static, str>::Owned(versao.into()) composer where the owned arm typing rules out the borrowed AsRef<str> return — reaches the wrapped String through this one dispatch, avoiding the pre-lift double-allocation (.as_str().to_owned() on the owned path would allocate a fresh String rather than reuse the wrapper’s own heap allocation).

Opens the trait-idiomatic owned-String reverse-projection axis on the substrate’s core String-wrapper newtype primitive CaixaVersion, mirroring the paired owned-String forward- projection family the sibling closed-set fieldless typed enums (crate::supervisor::RestartStrategy (7baa18a, first-mover), crate::supervisor::RestartPolicy (7851725), crate::CaixaKind (per its own doc block, third peer), plus the remaining twelve closed-set enums) already carry — Rust’s standard library does not derive From<Self> for String from From<String> for Self, so every newtype that carries a forward From<String> constructor but not the paired reverse-unwrap axis forces every call site through a .to_string() / .as_str().to_owned() detour that allocates fresh bytes rather than moving the wrapper’s own heap allocation.

Preserves the two-path split on the wrapped byte-string: the paired AsRef<str> and fmt::Display impls stay reachable for the borrowed &str and formatter-output paths, this impl closes the owned-String reverse axis. Same “one dispatch on the substrate primitive” discipline the peer forward From<String> for CaixaVersion / From<&str> for CaixaVersion constructors carry, now extended onto the owned-heap-string reverse projection.

Pinned load-bearing by [tests::caixa_version_from_into_owned_string_returns_wrapped_body] (byte-parity pin against CaixaVersion::as_str on the same instance) and [tests::caixa_version_from_into_owned_string_and_as_str_agree_on_every_shape] (cross-axis partition pin against the paired borrowed AsRef<str> impl and the sibling fmt::Display-routed ToString::to_string surface, plus a round-trip witness through the paired forward [From<String> for CaixaVersion] constructor closing the two-way Self → String → Self cycle by construction).

Source§

fn from(v: CaixaVersion) -> String

Converts to this type from the input type.
Source§

impl From<String> for CaixaVersion

Source§

fn from(s: String) -> Self

Converts to this type from the input type.
Source§

impl Hash for CaixaVersion

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for CaixaVersion

Source§

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

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

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

Inequality operator !=. Read more
Source§

impl Serialize for CaixaVersion

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for CaixaVersion

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<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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.