pub struct Api {
pub codex_id: CodexId,
pub conforms: TinyOrdSet<u16>,
pub default_call: Option<CallState>,
pub global: TinyOrdMap<StateName, GlobalApi>,
pub owned: TinyOrdMap<StateName, OwnedApi>,
pub aggregators: TinyOrdMap<MethodName, Aggregator>,
pub verifiers: TinyOrdMap<MethodName, CallId>,
pub errors: TinyOrdMap<u256, TinyString>,
}
Expand description
API is an interface implementation.
API should work without requiring runtime to have corresponding interfaces; it should provide all necessary data. Basically, one may think of API as a compiled interface hierarchy applied to a specific codex.
API does not commit to an interface, since it can match multiple interfaces in the interface hierarchy.
Fields§
§codex_id: CodexId
Commitment to the codex under which the API is valid.
conforms: TinyOrdSet<u16>
Interface standards to which the API conforms.
default_call: Option<CallState>
Name for the default API call and owned state name.
global: TinyOrdMap<StateName, GlobalApi>
State API defines how a structured global contract state is constructed out of (and converted into) UltraSONIC immutable memory cells.
owned: TinyOrdMap<StateName, OwnedApi>
State API defines how a structured owned contract state is constructed out of (and converted into) UltraSONIC destructible memory cells.
aggregators: TinyOrdMap<MethodName, Aggregator>
Readers have access to the converted global state
and can construct a derived state out of
it.
The typical examples when readers are used are to sum individual asset issues and compute the number of totally issued assets.
verifiers: TinyOrdMap<MethodName, CallId>
Links between named transaction methods defined in the interface - and corresponding verifier call ids defined by the contract.
NB: Multiple methods from the interface may call the came verifier.
errors: TinyOrdMap<u256, TinyString>
Maps error type reported by a contract verifier via EA
value to an error description taken
from the interfaces.
Implementations§
Source§impl Api
impl Api
Sourcepub fn codex_id(&self) -> CodexId
pub fn codex_id(&self) -> CodexId
Method returning copy of Api::codex_id
field.
Commitment to the codex under which the API is valid.
Sourcepub fn conforms(&self) -> &TinyOrdSet<u16>
pub fn conforms(&self) -> &TinyOrdSet<u16>
Method borrowing Api::conforms
field.
Interface standards to which the API conforms.
Sourcepub fn default_call(&self) -> &Option<CallState>
pub fn default_call(&self) -> &Option<CallState>
Method borrowing Api::default_call
field.
Name for the default API call and owned state name.
Sourcepub fn global(&self) -> &TinyOrdMap<StateName, GlobalApi>
pub fn global(&self) -> &TinyOrdMap<StateName, GlobalApi>
Method borrowing Api::global
field.
State API defines how a structured global contract state is constructed out of (and
Sourcepub fn owned(&self) -> &TinyOrdMap<StateName, OwnedApi>
pub fn owned(&self) -> &TinyOrdMap<StateName, OwnedApi>
Method borrowing Api::owned
field.
State API defines how a structured owned contract state is constructed out of (and converted
Sourcepub fn aggregators(&self) -> &TinyOrdMap<MethodName, Aggregator>
pub fn aggregators(&self) -> &TinyOrdMap<MethodName, Aggregator>
Method borrowing Api::aggregators
field.
Readers have access to the converted global state
and can construct a derived state out of
Sourcepub fn verifiers(&self) -> &TinyOrdMap<MethodName, CallId>
pub fn verifiers(&self) -> &TinyOrdMap<MethodName, CallId>
Method borrowing Api::verifiers
field.
Links between named transaction methods defined in the interface - and corresponding
Sourcepub fn errors(&self) -> &TinyOrdMap<u256, TinyString>
pub fn errors(&self) -> &TinyOrdMap<u256, TinyString>
Method borrowing Api::errors
field.
Maps error type reported by a contract verifier via EA
value to an error description taken
Source§impl Api
impl Api
pub fn api_id(&self) -> StrictHash
pub fn verifier(&self, method: impl Into<MethodName>) -> Option<CallId>
pub fn convert_global( &self, data: &StateData, sys: &TypeSystem, ) -> Result<Option<(StateName, StateAtom)>, StateConvertError>
pub fn convert_owned( &self, value: StateValue, sys: &TypeSystem, ) -> Result<Option<(StateName, StrictVal)>, StateConvertError>
pub fn build_immutable( &self, name: impl Into<StateName>, data: StrictVal, raw: Option<StrictVal>, sys: &TypeSystem, ) -> Result<StateData, StateBuildError>
pub fn build_destructible( &self, name: impl Into<StateName>, data: StrictVal, sys: &TypeSystem, ) -> Result<StateValue, StateBuildError>
pub fn build_witness( &self, name: impl Into<StateName>, data: StrictVal, sys: &TypeSystem, ) -> Result<StateValue, StateBuildError>
pub fn calculate( &self, name: impl Into<StateName>, ) -> Result<StateCalc, StateUnknown>
Trait Implementations§
Source§impl CommitEncode for Api
impl CommitEncode for Api
Source§type CommitmentId = StrictHash
type CommitmentId = StrictHash
Source§fn commit_encode(&self, engine: &mut CommitEngine)
fn commit_encode(&self, engine: &mut CommitEngine)
std::io::Write
writer instanceSource§impl<'de> Deserialize<'de> for Api
impl<'de> Deserialize<'de> for Api
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 Ord for Api
impl Ord for Api
Source§impl PartialOrd for Api
impl PartialOrd for Api
Source§impl StrictDecode for Api
impl StrictDecode for Api
fn strict_decode(reader: &mut impl TypedRead) -> Result<Self, DecodeError>
fn strict_read(reader: impl ReadRaw) -> Result<Self, DecodeError>
Source§impl StrictDumb for Api
impl StrictDumb for Api
fn strict_dumb() -> Self
Source§impl StrictEncode for Api
impl StrictEncode for Api
fn strict_encode<W: TypedWrite>(&self, writer: W) -> Result<W>
fn strict_write(&self, writer: impl WriteRaw) -> Result<(), Error>
Source§impl StrictStruct for Api
impl StrictStruct for Api
const ALL_FIELDS: &'static [&'static str]
fn strict_check_fields()
fn strict_type_info() -> TypeInfo<Self>
Source§impl StrictType for Api
impl StrictType for Api
const STRICT_LIB_NAME: &'static str = LIB_NAME_SONIC
fn strict_name() -> Option<TypeName>
impl Eq for Api
impl StrictProduct for Api
Auto Trait Implementations§
impl Freeze for Api
impl RefUnwindSafe for Api
impl Send for Api
impl Sync for Api
impl Unpin for Api
impl UnwindSafe for Api
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<T> CommitId for Twhere
T: CommitEncode,
impl<T> CommitId for Twhere
T: CommitEncode,
fn commit(&self) -> CommitEngine
Source§fn commit_id(&self) -> <T as CommitEncode>::CommitmentId
fn commit_id(&self) -> <T as CommitEncode>::CommitmentId
Source§impl<T> CommitmentLayout for Twhere
T: CommitEncode + StrictDumb,
impl<T> CommitmentLayout for Twhere
T: CommitEncode + StrictDumb,
Source§fn commitment_layout() -> CommitLayout
fn commitment_layout() -> CommitLayout
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
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.