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 Contractwhere
*const u8 is !null: Freeze,
PhantomData<u8>: Freeze,
PhantomData<IfaceId>: Freeze,
PhantomData<Resource>: Freeze,
*const LeafNode<String, Requirement> is !null: Freeze,
PhantomData<(Owned, LeafOrInternal)>: Freeze,
PhantomData<Box<(String, Requirement)>>: Freeze,
*const LeafNode<String, Artifact> is !null: Freeze,
PhantomData<Box<(String, Artifact)>>: Freeze,
impl Move for Contract
impl RefUnwindSafe for Contract
impl Send for Contractwhere
RawVecInner: Send,
NodeRef<Owned, String, ParamType, LeafOrInternal>: Send,
BoxRaw<(String, ParamType)>: Send,
NodeRef<Owned, String, Value, LeafOrInternal>: Send,
BoxRaw<(String, Value)>: Send,
NodeRef<Owned, String, Deadband, LeafOrInternal>: Send,
BoxRaw<(String, Deadband)>: Send,
NodeRef<Owned, String, Requirement, LeafOrInternal>: Send,
BoxRaw<(String, Requirement)>: Send,
NodeRef<Owned, String, Artifact, LeafOrInternal>: Send,
BoxRaw<(String, Artifact)>: Send,
impl Sync for Contractwhere
RawVecInner: Sync,
NodeRef<Owned, String, ParamType, LeafOrInternal>: Sync,
BoxRaw<(String, ParamType)>: Sync,
NodeRef<Owned, String, Value, LeafOrInternal>: Sync,
BoxRaw<(String, Value)>: Sync,
NodeRef<Owned, String, Deadband, LeafOrInternal>: Sync,
BoxRaw<(String, Deadband)>: Sync,
NodeRef<Owned, String, Requirement, LeafOrInternal>: Sync,
BoxRaw<(String, Requirement)>: Sync,
NodeRef<Owned, String, Artifact, LeafOrInternal>: Sync,
BoxRaw<(String, Artifact)>: Sync,
impl Unpin for Contractwhere
*const u8 is !null: Unpin,
*const LeafNode<String, ParamType> is !null: Unpin,
Box<(String, ParamType)>: Unpin,
*const LeafNode<String, Value> is !null: Unpin,
Box<(String, Value)>: Unpin,
*const LeafNode<String, Deadband> is !null: Unpin,
Box<(String, Deadband)>: Unpin,
*const LeafNode<String, Requirement> is !null: Unpin,
Box<(String, Requirement)>: Unpin,
*const LeafNode<String, Artifact> is !null: Unpin,
Box<(String, Artifact)>: Unpin,
impl UnsafeUnpin for Contractwhere
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
PhantomData<IfaceId>: UnsafeUnpin,
PhantomData<Resource>: UnsafeUnpin,
*const LeafNode<String, Requirement> is !null: UnsafeUnpin,
PhantomData<(Owned, LeafOrInternal)>: UnsafeUnpin,
PhantomData<Box<(String, Requirement)>>: UnsafeUnpin,
*const LeafNode<String, Artifact> is !null: UnsafeUnpin,
PhantomData<Box<(String, Artifact)>>: UnsafeUnpin,
impl UnwindSafe for Contractwhere
RawVecInner: UnwindSafe,
BTreeMap<String, ParamType>: UnwindSafe,
BTreeMap<String, Value>: UnwindSafe,
BTreeMap<String, Deadband>: UnwindSafe,
BTreeMap<String, Requirement>: UnwindSafe,
BTreeMap<String, Artifact>: UnwindSafe,
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