pub struct Contract { /* private fields */ }Expand description
The wire-semantics Contract consumed by host runtimes.
declarations supplies named roots for the arena. Comments, source spelling,
and raw source are kept in the SourceInfo sidecar (compiler feature),
not here.
Implementations§
Source§impl Contract
impl Contract
pub fn format(&self) -> &str
pub fn format_version(&self) -> u32
pub fn semantics_profile(&self) -> &str
pub fn canonicalization_profile(&self) -> &str
pub fn identities(&self) -> &ContractIdentities
pub fn contract_id(&self) -> &str
pub fn interface_id(&self) -> Option<&str>
pub fn producer(&self) -> &ProducerInfo
pub fn types(&self) -> &[TypeNode]
pub fn declarations(&self) -> &[Declaration]
pub fn actor(&self) -> Option<&Actor>
Sourcepub fn validate(&self) -> Result<(), ContractValidationError>
pub fn validate(&self) -> Result<(), ContractValidationError>
Validate graph structure and verify its content identities.
pub fn validate_with_limits( &self, limits: &Limits, ) -> Result<(), ContractValidationError>
pub fn validate_with_context( &self, context: &RuntimeContext, ) -> Result<(), ContractValidationError>
Sourcepub fn canonicalize(&self) -> Result<Self, ContractValidationError>
pub fn canonicalize(&self) -> Result<Self, ContractValidationError>
Return a deterministically re-indexed copy with freshly calculated identities. This is useful at JSON trust boundaries.
pub fn canonicalize_with_limits( &self, limits: &Limits, ) -> Result<Self, ContractValidationError>
pub fn canonicalize_with_context( &self, context: &RuntimeContext, ) -> Result<Self, ContractValidationError>
Sourcepub fn to_json_pretty(&self) -> Result<String, ContractValidationError>
pub fn to_json_pretty(&self) -> Result<String, ContractValidationError>
Serialize validated canonical JSON under Limits::default.
A Contract built with raised limits can fail here. Use
Self::to_json_pretty_with_limits or
Self::to_json_pretty_with_context to serialize under the caller’s
own policy.
Sourcepub fn to_json_pretty_with_limits(
&self,
limits: &Limits,
) -> Result<String, ContractValidationError>
pub fn to_json_pretty_with_limits( &self, limits: &Limits, ) -> Result<String, ContractValidationError>
Serialize validated canonical JSON under caller-supplied limits.
This revalidates and recanonicalizes, so it consumes the structural
limits construction consumed and charges the rendered length against
max_canonicalization_work. Raising only the limit that gated
construction is therefore not always sufficient; see
Self::to_json_pretty_with_context.
Sourcepub fn to_json_pretty_with_context(
&self,
context: &RuntimeContext,
) -> Result<String, ContractValidationError>
pub fn to_json_pretty_with_context( &self, context: &RuntimeContext, ) -> Result<String, ContractValidationError>
Serialize validated canonical JSON under the caller’s context.
Consumes two distinct budgets: the structural limits that gated
construction, and max_canonicalization_work, against which the
rendered byte length is charged. A caller who raised only a structural
limit (for example max_string_bytes) to build the Contract may still
need to raise max_canonicalization_work to render it.
For a completely unbounded render, serde Serialize is implemented
on Contract directly; it consults no limits and performs no
revalidation. That path is for trusted, already-validated values.
Sourcepub fn from_json(input: &str) -> Result<Self, ContractJsonError>
pub fn from_json(input: &str) -> Result<Self, ContractJsonError>
Parse, validate, and canonicalize a Contract JSON document under
Limits::default.
pub fn from_json_with_limits( input: &str, limits: &Limits, ) -> Result<Self, ContractJsonError>
Sourcepub fn from_json_with_context(
input: &str,
context: &RuntimeContext,
) -> Result<Self, ContractJsonError>
pub fn from_json_with_context( input: &str, context: &RuntimeContext, ) -> Result<Self, ContractJsonError>
Bounded parse: max_input_bytes is enforced before the document is
decoded, and decode and validation share one budget.
Sourcepub fn from_slice_with_limits(
input: &[u8],
limits: &Limits,
) -> Result<Self, ContractJsonError>
pub fn from_slice_with_limits( input: &[u8], limits: &Limits, ) -> Result<Self, ContractJsonError>
Parse, validate, and canonicalize Contract JSON bytes under caller-supplied limits.
Sourcepub fn from_slice_with_context(
input: &[u8],
context: &RuntimeContext,
) -> Result<Self, ContractJsonError>
pub fn from_slice_with_context( input: &[u8], context: &RuntimeContext, ) -> Result<Self, ContractJsonError>
Bounded parse from bytes. Equivalent to Self::from_json_with_context
without requiring the caller to validate UTF-8 first.
pub fn try_from_raw(raw: RawContract) -> Result<Self, ContractValidationError>
pub fn try_from_raw_with_limits( raw: RawContract, limits: &Limits, ) -> Result<Self, ContractValidationError>
pub fn try_from_raw_with_context( raw: RawContract, context: &RuntimeContext, ) -> Result<Self, ContractValidationError>
Source§impl Contract
impl Contract
pub fn bind_type( &self, type_ref: TypeRef, ) -> Result<ContractTypeRef, HostValueValidationError>
pub fn bind_method( &self, method: impl Into<String>, ) -> Result<ContractMethodRef, HostValueValidationError>
Trait Implementations§
impl Eq for Contract
Source§impl From<&Contract> for RawContract
impl From<&Contract> for RawContract
impl StructuralPartialEq for Contract
Auto Trait Implementations§
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.