Skip to main content

Module samples

Module samples 

Source
Expand description

Built-in demo chunks assembled with crate::ChunkBuilder.

Use these as runnable specs of the messaging contract (and as regression tests). Prefer copying a sample over inventing hop register layouts from scratch.

SampleShows
add_forty_twoScalar VM path (no natives)
ping_pongCap spawn + Atomic Hop round-trip
atomic_request_replyTagged REQ/REP + print
selective_receiveReceiveMatch FIFO skip
ask_replyAsk RPC hop
forged_sender_send / forged_sender_askS1: forged make_msg sender dies
boomImmediate trap (supervisor demos)

Hop samples require crate::std_native_table.

Constants§

TAG_JUNK
Decoy hop for selective_receive ÔÇö must be skipped by ReceiveMatch.
TAG_PING
TAG_PONG
TAG_REP
TAG_REQ
Protocol tags for Atomic Hop samples.

Functions§

add_forty_two
r0 = 41 + 1; return r0 ÔÇö the 60-second sanity chunk.
ask_reply
Atomic request/reply via Opcode::Ask (RPC hop).
atomic_request_reply
Atomic request-reply with crate::Value::Message (one envelope per hop).
boom
Immediate Trap ÔÇö used to show crate::Supervisor restart.
forged_sender_ask
Same security property as forged_sender_send, via Opcode::Ask.
forged_sender_send
Security regression sample: forged make_msg sender must not survive Send.
ping_pong
Two flows, one Atomic Hop round-trip: main sends a Message to pong, pong replies with payload+1 via msg_reply_cap, main returns that payload (2).
selective_receive
Selective Atomic Hop: server waits for TAG_REQ while a TAG_JUNK hop sits ahead in the mailbox (FIFO skip, not drop).