pub struct Contract {
pub iface: IfaceId,
pub minor: Option<u32>,
pub summary: Option<String>,
pub uses: Vec<IfaceId>,
pub resources: Vec<Resource>,
pub requires: BTreeMap<String, Requirement>,
pub artifacts: BTreeMap<String, Artifact>,
}Expand description
A valid contract, every default expanded.
Fields§
§iface: IfaceId§minor: Option<u32>Informative; not in the fingerprint.
summary: Option<String>Documentation; not in the fingerprint.
uses: Vec<IfaceId>The profiles used, sorted.
resources: Vec<Resource>Sorted by (kind token, template).
requires: BTreeMap<String, Requirement>§artifacts: BTreeMap<String, Artifact>Every schema artifact the contract lists or references, by id.
Implementations§
Source§impl Contract
impl Contract
Sourcepub fn resource(&self, token: KindToken, template: &str) -> Option<&Resource>
pub fn resource(&self, token: KindToken, template: &str) -> Option<&Resource>
The resource declared under token with this exact template.
Sourcepub fn packed_layout(&self, ty: &TypeId) -> Result<Option<Layout>, String>
pub fn packed_layout(&self, ty: &TypeId) -> Result<Option<Layout>, String>
The layout of a packed type this contract references (core §7.6),
read from its artifact: None for a type of another kind, Err
naming why a packed one has none (an artifact missing, as a bundle
read without its schemas would leave it, or a declaration with a
finding).
§Errors
The reason, in words.
Source§impl Contract
impl Contract
Sourcepub fn from_bundle(b: &Bundle) -> Result<Self, BundleError>
pub fn from_bundle(b: &Bundle) -> Result<Self, BundleError>
The contract model inside a bundle, read from its canonical form
(spec §9.5, §9.6). minor, summary and every doc are None:
the canonical form excludes them. Bundle::build of the result is
the bundle given, byte for byte, so a bundle built once (by
zk2 contract bundle, or embedded by codegen) is never rebuilt
differently (#611).
The bundle should come from Bundle::verify: this reads its shape
and refuses what is not a canonical contract
(BundleError::Shape), but checks no hash.
§Errors
A contract whose format is not this version’s, or whose shape is
not the canonical form’s.
Trait Implementations§
Auto Trait Implementations§
impl Forget for Contract
impl Freeze for Contract
impl RefUnwindSafe for Contract
impl Send for Contract
impl Sync for Contract
impl Unpin for Contract
impl UnsafeUnpin for Contract
impl UnwindSafe for Contract
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more