Skip to main content

Contract

Trait Contract 

Source
pub trait Contract: Send + Sync {
    type Family: ContractFamily;
    type Category: EntityCategory;

    // Required methods
    fn family(&self) -> &Self::Family;
    fn version(&self) -> &SpecVersion;
    fn groups(&self) -> &[Group];
    fn entities(&self, group: &Group) -> &[Entity<Self::Category>];
    fn link_context(&self, opts: &Options) -> LinkContext;

    // Provided methods
    fn group_overview(&self, group: &Group) -> Option<&str> { ... }
    fn companions(&self) -> &[CompanionFile] { ... }
}
Expand description

A loaded, resolved contract ready to render or serialize.

Parser crates implement this trait after parsing and resolving references. The sync API supports in-memory traversal during manual assembly.

Required Associated Types§

Source

type Family: ContractFamily

Contract family metadata and capabilities.

Source

type Category: EntityCategory

Family-specific entity category type.

Required Methods§

Source

fn family(&self) -> &Self::Family

Returns the contract family identity for this loaded instance.

Source

fn version(&self) -> &SpecVersion

Returns the parsed spec version for this contract instance.

Source

fn groups(&self) -> &[Group]

Returns all groups in this contract (entities are queried per group).

Source

fn entities(&self, group: &Group) -> &[Entity<Self::Category>]

Returns entities belonging to group.

Builds a LinkContext for cross-reference formatting under opts.

Provided Methods§

Source

fn group_overview(&self, group: &Group) -> Option<&str>

Returns optional overview prose for group, when the family provides it.

Source

fn companions(&self) -> &[CompanionFile]

Returns parser-side companion files discovered for this contract.

Default empty; families with companion docs override. Convert to wire Companion via companion_files_to_stored.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§