manifold:storage 0.2.0
Contract reference · Payloads · contract.json (crates/manifold-wasm-abi/wit/contract.json)
Contract 0.2.0, track 0.2: open, unreleased. Nothing on track 0.2 is released yet, so any item may still change in place (spec §7.2).
| Interface | Kind | Consent | Sides | Owner |
|---|---|---|---|---|
blob-store | import | operator | server | enki |
storage-types | types-only | silent | both | contract-foundation |
Interface blob-store
import · consent operator · sides server · owner enki · since 0.2.0
Mod blob storage in the world save (Enki B §7): per world, or per world
and player. Server side; consent class operator (server disk against a
quota, contract foundation §10.2).
Operations keep the deferred shape (Enki B §0): each call returns a
request id, and its result arrives through take-completions. Both hosts
run the operation during the call, so every result is ready at the next
drain (Enki B issue 32). Writes reach the save with the world’s next save
transaction, so blobs never disagree with the chunks on disk.
Functions
delete
delete: func(key: blob-key) -> u64
list
list: func(scope: scope, player: option<player-id>, prefix: string) -> u64
Blobs in a scope whose paths start with prefix, in path order.
quota
quota: func(scope: scope, player: option<player-id>) -> quota-info
Bytes used and allowed in a scope; zero used outside a system.
read
read: func(key: blob-key) -> u64
take-completions
take-completions: func() -> list<tuple<u64, result<completion, blob-error>>>
Results since the last call, in request order.
write
write: func(key: blob-key, bytes: list<u8>) -> u64
Create or replace. Over the scope’s quota it fails with
quota-exceeded and changes nothing.
bytes: opaque bytesblob-contents.
Types
blob-error (variant)
io carries diagnostic text. outside-system: the call was made
outside one of the mod’s server systems, where the host lends no
world.
| Index | Case | Payload | About |
|---|---|---|---|
| 0 | invalid-path | none | |
| 1 | not-found | none | |
| 2 | quota-exceeded | none | |
| 3 | io | string | |
| 4 | cancelled | none | |
| 5 | wrong-side | none | |
| 6 | outside-system | none |
blob-info (alias)
= storage/storage-types.blob-info
blob-key (alias)
= storage/storage-types.blob-key
completion (variant)
A successful operation. read carries the blob’s bytes.
| Index | Case | Payload | About |
|---|---|---|---|
| 0 | read | list<u8> | |
| 1 | written | none | |
| 2 | deleted | none | |
| 3 | listed | list<blob-info> |
read: opaque bytesblob-contents.
player-id (alias)
= core/types.player-id
quota-info (alias)
= storage/storage-types.quota-info
scope (alias)
= storage/storage-types.scope
Interface storage-types
types-only · consent silent · sides both · owner contract-foundation · since 0.2.0
Records the storage interfaces share with each other and with
manifold:world/block-transaction’s undo records (contract foundation
§4.5 rule 2; Enki B §7.2). Types only: importing this interface links
nothing and needs no consent.
Types
blob-info (record)
A stored blob: its path, size in bytes and modification time in milliseconds since the Unix epoch.
| Field | Type | About |
|---|---|---|
path | string | |
size | u64 | |
modified-ms | u64 |
blob-key (record)
A blob of the calling mod. The host adds the mod id it authenticated;
a guest never names another mod’s blobs. player names the player of
a world-player blob and is none for a world one. path is up to 8
/-separated segments of [A-Za-z0-9._-], at most 256 bytes.
| Field | Type | About |
|---|---|---|
scope | scope | |
player | option<player-id> | |
path | string |
player-id (alias)
= core/types.player-id
quota-info (record)
Bytes used and allowed in one scope.
| Field | Type | About |
|---|---|---|
used | u64 | |
limit | u64 |
scope (enum)
Where a server blob lives (Enki B §7.1): per world and mod, or per
world, mod and player. Files on the player’s machine are
local-files, a separate interface (contract foundation §10.2).
| Index | Case | About |
|---|---|---|
| 0 | world | |
| 1 | world-player |