Skip to main content

sim_lib_control/
claims.rs

1use sim_kernel::{
2    Cx, LibId, OpKey, Result, Symbol,
3    standard::{publish_organ_claims, publish_organ_claims_for_lib, standard_control_op_key},
4};
5
6/// Returns the `organ/control` symbol identifying this control organ.
7pub fn control_organ_symbol() -> Symbol {
8    Symbol::qualified("organ", "control")
9}
10
11/// Returns the standard control operation keys this organ claims:
12/// `prompt`, `capture`, `abort`, and `resume`.
13pub fn control_op_keys() -> Vec<OpKey> {
14    ["prompt", "capture", "abort", "resume"]
15        .into_iter()
16        .map(standard_control_op_key)
17        .collect()
18}
19
20/// Publishes the control organ's claims into `cx`, recording that this organ
21/// supplies the standard [`control_op_keys`] under [`control_organ_symbol`].
22pub fn publish_control_organ_claims(cx: &mut Cx) -> Result<()> {
23    publish_organ_claims(cx, control_organ_symbol(), control_op_keys())
24}
25
26/// Publishes control organ claims as part of a loaded lib receipt.
27pub fn publish_control_organ_claims_for_lib(cx: &mut Cx, lib_id: LibId) -> Result<()> {
28    publish_organ_claims_for_lib(cx, lib_id, control_organ_symbol(), control_op_keys())
29}