Expand description
Ordered chain of flow supplements in front of an owner.
install_supplement_door adds a door function to a Program. The
host spawns it with the owner Cap in r0. The door registers
registry_name and then serves three Asks:
| Tag | Payload | Effect |
|---|---|---|
TAG_SUPP_ATTACH | record [index: Int, cap: Cap] | Insert that Cap at index (index == len appends). |
TAG_SUPP_DETACH | Int index | Remove that slot. |
TAG_SUPP_ENTER | any value | Walk the chain, then deliver what remains to the owner. |
Each supplement receives TAG_SUPP_JUDGE and answers
TAG_SUPP_FOLLOW (keep the value), TAG_SUPP_REJECT (stop; the
owner is not asked), or TAG_SUPP_REPLACE (continue with the reply
payload). A supplement that exits first is TAG_SUPP_REJECT: the
door does not skip a dead step. The owner is asked with
TAG_SUPP_DELIVER and uses the same three answers. The door’s reply
to the caller is TAG_SUPP_FOLLOW with the final value, or
TAG_SUPP_REJECT.
The chain is eight Cap registers inside the door. Tables cannot store
a Cap, and list_get takes a constant index, so the walk is unrolled.
Nothing in this module hooks mailbox delivery: the door is an ordinary
flow, and the caller chooses it by Cap.
§Addressing
Ask needs CapRights::ASK. Bytecode
Fn::whereis mints only
CapRights::SEND. The name the door
registers stores an
CapRights::ADDRESSING token whose
holder is the door. Pass that token from Runtime::whereis
as a spawn argument; the runtime reissues it to the caller with ASK.
The door calls make_msg, msg_tag, msg_payload, msg_request_id,
and msg_reply_cap. Start the runtime with std_native_table.
When the door exits, the scheduler revokes every Cap the door holds and sweeps the registry name. Caps the host still holds stay valid.
use byteflow::{install_supplement_door, Program};
fn main() -> Result<(), byteflow::SupplementError> {
let mut program = Program::new("chain");
let _door = install_supplement_door(&mut program, "front")?;
let _chunk = program.build();
Ok(())
}Enums§
- Supplement
Error - Why a door could not be added to the program.
Constants§
- SUPPLEMENT_
SLOTS - Slots in one door. Index
0is asked first. - TAG_
SUPP_ ATTACH - Caller → door: insert a Cap. Payload is record
[index, cap]. - TAG_
SUPP_ DELIVER - Door → owner: the value the chain allowed through.
- TAG_
SUPP_ DETACH - Caller → door: drop the slot at this
Intindex. - TAG_
SUPP_ ENTER - Caller → door: judge
payload, then deliver what the chain left. - TAG_
SUPP_ FOLLOW - Keep the value and continue.
- TAG_
SUPP_ JUDGE - Door → supplement: judge this value.
- TAG_
SUPP_ REJECT - Stop the chain. The owner is not asked.
- TAG_
SUPP_ REPLACE - Continue with the reply payload in place of the current value.
Functions§
- install_
supplement_ door - Add the door and its judge helper to
program. - supplement_
attach Askthe door to insertcapatindex(Int).index == lenappends. A successful reply’s payload is the new length.- supplement_
detach Askthe door to drop the slot atindex(Int). A successful reply’s payload is the new length.- supplement_
enter Askthe door to judgepayload. The reply hop isTAG_SUPP_FOLLOWorTAG_SUPP_REJECT.