// cap.narrow.prefix to /etc under scope /data: the err edge carries the cap_error. // expect: run // grant: fs=fs.read:/data // result: 2 // equivalent: phase2/run/narrow_not_subset.air // phase: 6 // spec: docs/spec/15-source-language.md module demo.narrownot_subset fn classify(fs: cap, path: slice) -> u8 effects [] { match cap.narrow.prefix(fs, path) { ok(c) => 0, err(e) => match e { cap_error::invalid_restriction => 1, cap_error::not_subset => 2, cap_error::unsupported_restriction => 3, }, } } fn main(fs: cap) -> u8 effects [] { classify(fs, b"/etc") }