#[repr(C)]pub struct ContractSpecId {
pub crate_name: ContractSpecString,
pub major: ContractSpecString,
pub module_path: ContractSpecString,
pub declared: ContractSpecString,
}Expand description
The identity of a user-defined type or event.
Every spec-named item — a #[contract_type], a #[contract_exception], a
#[derive(Event)] — is named by one of these, and every reference to one
resolves through it. A bare identifier cannot tell two of them apart: two
crates, two modules of one crate, or two major versions of one crate may
each declare a Transfer, and a spec naming both could not say which is
which.
The segments are carried apart rather than joined into
CRATE@MAJOR::module::path::Name, because the joined form cannot be split
back. name = "..." on a spec-named item substitutes its value verbatim —
a value carrying :: spells its own segments and nothing rejects it — so
the boundary between the module path and the declared name is not
recoverable from the string. Consumers that need a display name or a
target-language identifier read declared directly; how an id is shortened
for display stays each codegen’s business.
Fields§
§crate_name: ContractSpecString§major: ContractSpecString§module_path: ContractSpecString§declared: ContractSpecStringTrait Implementations§
Source§impl Clone for ContractSpecId
impl Clone for ContractSpecId
Source§impl ConstMaxSize for ContractSpecId
impl ConstMaxSize for ContractSpecId
Source§impl ConstMaxSize for ContractSpecId
impl ConstMaxSize for ContractSpecId
Source§impl Debug for ContractSpecId
impl Debug for ContractSpecId
Source§impl<'de> Deserialize<'de> for ContractSpecId
impl<'de> Deserialize<'de> for ContractSpecId
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Display for ContractSpecId
module_path::declared (crate_name@major): an id the way a person reading
a diagnostic wants it.
impl Display for ContractSpecId
module_path::declared (crate_name@major): an id the way a person reading
a diagnostic wants it.
Not the joined CRATE@MAJOR::module::path::Name form: a reader wants to
see which segment is which, and module_path already leads with the crate,
so the crate and major trail in parentheses rather than doubling up in the
path.
Only for messages. The rendering is one-way – declared may itself carry
::, so where the module path ends cannot be recovered from the text –
and ids are compared and keyed whole, never by this.
Lossy: nothing on the wire makes a segment UTF-8, and a diagnostic is the
wrong place to fail, so an invalid sequence renders as U+FFFD, exactly as
String::from_utf8_lossy has it. Segments are decoded rather than written
through ContractSpecString’s own Display, which hex-escapes every
non-ASCII byte, because a Rust identifier may be non-ASCII. Validate the
segments first wherever their bytes matter.
impl EncodesAs<ContractSpecId> for ContractSpecId
impl Eq for ContractSpecId
Source§impl Hash for ContractSpecId
impl Hash for ContractSpecId
Source§impl JsonSchema for ContractSpecId
impl JsonSchema for ContractSpecId
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read moreSource§impl Ord for ContractSpecId
impl Ord for ContractSpecId
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for ContractSpecId
impl PartialEq for ContractSpecId
Source§impl PartialOrd for ContractSpecId
impl PartialOrd for ContractSpecId
Source§impl<'_r> ReadXDR<'_r> for ContractSpecId
impl<'_r> ReadXDR<'_r> for ContractSpecId
Source§fn read_xdr<R: Reader<'_r>>(r: &mut R) -> ReadResult<Self>
fn read_xdr<R: Reader<'_r>>(r: &mut R) -> ReadResult<Self>
Source§fn read_xdr_in_place<'__xdrs_s, R: Reader<'_r>>(
r: &mut R,
__xdrs_slot: Slot<'__xdrs_s, Self>,
) -> ReadResult<Init<'__xdrs_s, Self>>
fn read_xdr_in_place<'__xdrs_s, R: Reader<'_r>>( r: &mut R, __xdrs_slot: Slot<'__xdrs_s, Self>, ) -> ReadResult<Init<'__xdrs_s, Self>>
slot, without first building it
on the stack. Read more