Skip to main content

Region

Reference for mo:core/Region in the core library.

Region exposes low-level stable-memory operations. The functions are trusted runtime calls; verify your own bounds and layout invariants before loading from or storing to offsets.

Import

mo:core/Region

Status

  • Runtime module

Public API

Types

  • Region

Functions

new() : Region

Allocates or extends the runtime resource represented by this module.

Use when: code or specifications need this operation with the documented contract.

id(region : Region) : Nat

Returns the runtime identifier for the region.

Use when: code or specifications need this operation with the documented contract.

size(region : Region) : Nat64

Returns the length or cardinality represented by the value.

Use when: code or specifications need this operation with the documented contract.

grow(region : Region, newPages : Nat64) : Nat64

Allocates or extends the runtime resource represented by this module.

Use when: code or specifications need this operation with the documented contract.

loadNat8(region : Region, offset : Nat64) : Nat8

Reads the requested value from the structure.

Use when: reading this value is part of an implementation or postcondition.

storeNat8(region : Region, offset : Nat64, value : Nat8)

Returns or applies the corresponding update to the structure.

Use when: the postcondition must relate the updated value to the previous one.

loadNat16(region : Region, offset : Nat64) : Nat16

Reads the requested value from the structure.

Use when: reading this value is part of an implementation or postcondition.

storeNat16(region : Region, offset : Nat64, value : Nat16)

Returns or applies the corresponding update to the structure.

Use when: the postcondition must relate the updated value to the previous one.

loadNat32(region : Region, offset : Nat64) : Nat32

Reads the requested value from the structure.

Use when: reading this value is part of an implementation or postcondition.

storeNat32(region : Region, offset : Nat64, value : Nat32)

Returns or applies the corresponding update to the structure.

Use when: the postcondition must relate the updated value to the previous one.

loadNat64(region : Region, offset : Nat64) : Nat64

Reads the requested value from the structure.

Use when: reading this value is part of an implementation or postcondition.

storeNat64(region : Region, offset : Nat64, value : Nat64)

Returns or applies the corresponding update to the structure.

Use when: the postcondition must relate the updated value to the previous one.

Summary

  • Runtime module under mo:core/Region.
  • Exposes 12 public functions.