// Selector is the programmatic representation of an IPLD Selector Node
// and can be applied to traverse a given IPLD DAG
typeSelectorinterface{
Interests()[]PathSegment// returns the segments we're likely interested in **or nil** if we're a high-cardinality or expression based matcher and need all segments proposed to us.
Explore(ipld.Node,PathSegment)Selector// explore one step -- iteration comes from outside (either whole node, or by following suggestions of Interests). returns nil if no interest. you have to traverse to the next node yourself (the selector doesn't do it for you because you might be considering multiple selection reasons at the same time).
Decide(ipld.Node)bool
}
// ParseSelector creates a Selector that can be traversed from an IPLD Selector node
funcParseSelector(nipld.Node)(Selector,error){
ifn.ReprKind()!=ipld.ReprKind_Map{
returnnil,fmt.Errorf("selector spec parse rejected: selector is a keyed union and thus must be a map")