Skip to main content

segments

Function segments 

Source
fn segments(path: &str) -> Vec<&str>
Expand description

Split one path into the segments this index routes on: . separates them, and an [index] subscript is a segment of its own rather than part of the field name it follows.

Both halves of the convention exist because the write path that produces a Change::path writes an array element as tags[0] and a nested one as labels.values[0].val (see didbot_pds::policy::diff). Splitting on . alone would make tags[0] a single opaque segment that the declared prefix tags could never be an ancestor of — so a policy guarding a field would silently stop guarding it the moment that field held an array, while the identical policy over a scalar field worked. A prefix can still name a specific element (tags[0]) by writing the subscript out; it segments the same way on both sides.