pub trait KernelAssist {
// Required methods
fn gas_meter_get(&self, meter_id: MeterId) -> u64;
fn gas_meter_set(&mut self, meter_id: MeterId, value: u64) -> u64;
fn storage_quota_get(&self, quota_id: QuotaId) -> u64;
fn storage_quota_set(&mut self, quota_id: QuotaId, value: u64) -> u64;
fn yield_catcher_markers(&self, catcher_hash: CapHash) -> Vec<CapHash> ⓘ;
fn yield_catcher_add(
&mut self,
catcher_hash: CapHash,
marker_instance_hash: CapHash,
);
fn yield_catcher_remove(
&mut self,
catcher_hash: CapHash,
marker_instance_hash: CapHash,
);
fn yield_catcher_new(&mut self) -> CapHash;
// Provided methods
fn host_open(&mut self, _file_id: u64) -> Option<CapHashOrRef> { ... }
fn host_save(
&mut self,
_data: CapHashOrRef,
_quota_id: u64,
_size: u64,
) -> Option<u64> { ... }
}Expand description
The integration point for kernel-assisted Instances.
Stage 3 wires the Vm to call these methods at:
- per-instruction gas debit (gas_meter_*),
- host_yield routing (yield_catcher_*),
- host_mint_data_cap quota debit (storage_quota_*),
- host_open / host_save resolved via cache references.
Methods on &self are reads; methods on &mut self are state
mutations. Atomic semantics where the spec requires it
(*_set returns the previous value).
Required Methods§
Sourcefn gas_meter_get(&self, meter_id: MeterId) -> u64
fn gas_meter_get(&self, meter_id: MeterId) -> u64
Read the remaining gas for meter_id. Missing entry → 0.
Sourcefn gas_meter_set(&mut self, meter_id: MeterId, value: u64) -> u64
fn gas_meter_set(&mut self, meter_id: MeterId, value: u64) -> u64
Atomically GasMeter[meter_id] := value; return previous value
(or 0 if no entry existed).
fn storage_quota_get(&self, quota_id: QuotaId) -> u64
fn storage_quota_set(&mut self, quota_id: QuotaId, value: u64) -> u64
Sourcefn yield_catcher_markers(&self, catcher_hash: CapHash) -> Vec<CapHash> ⓘ
fn yield_catcher_markers(&self, catcher_hash: CapHash) -> Vec<CapHash> ⓘ
Read the marker list for a YieldCatcher instance identified by
catcher_hash. Order matters: routing walks the list and takes
the first match.
Sourcefn yield_catcher_add(
&mut self,
catcher_hash: CapHash,
marker_instance_hash: CapHash,
)
fn yield_catcher_add( &mut self, catcher_hash: CapHash, marker_instance_hash: CapHash, )
Add a marker template to the catcher’s list.
Sourcefn yield_catcher_remove(
&mut self,
catcher_hash: CapHash,
marker_instance_hash: CapHash,
)
fn yield_catcher_remove( &mut self, catcher_hash: CapHash, marker_instance_hash: CapHash, )
Remove a marker template. No-op if absent.
Sourcefn yield_catcher_new(&mut self) -> CapHash
fn yield_catcher_new(&mut self) -> CapHash
Mint a fresh empty YieldCatcher. Returns its content hash (which the caller stores as a Cap::Instance[YieldCatcher]).