Skip to main content

ContractTypeName

Trait ContractTypeName 

Source
pub trait ContractTypeName {
    const NAME: ContractSpecIdView<'static>;
}
Expand description

Provides the spec-visible name for a contract type.

Required Associated Constants§

Source

const NAME: ContractSpecIdView<'static>

The fully qualified id this type is known by in the contract spec.

This is an identity claim, not a label. A bare ident cannot tell two user-defined types apart — two crates, two modules of one crate, or two major versions of one crate may each define a Meta — so every reference in a spec resolves through this const, and two types agree on an id only if they are the same type. The crate and major-version segments are load-bearing: shortening an id to its declared name for display is each codegen’s business, not the spec’s.

The segments travel apart rather than joined into CRATE@MAJOR::module::path::Name, because the joined form cannot be split back: name = "..." substitutes its value verbatim, :: and all, so the boundary between module path and declared name is not recoverable from the string.

#[contract_type] and #[contract_exception] derive it at the declaration, where module_path!() and the declaring crate’s name and version are all in scope, so it cannot be taken from the wrong crate. A hand-written impl (for a type this crate does not declare) is asserting the id itself and is responsible for its accuracy, segment by segment.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§