DescribeIterator returns a description of the iterator tree.
(it Iterator)
| 139 | |
| 140 | // DescribeIterator returns a description of the iterator tree. |
| 141 | func DescribeIterator(it Iterator) Description { |
| 142 | sz, exact := it.Size() |
| 143 | d := Description{ |
| 144 | UID: uint64(reflect.ValueOf(it).Pointer()), |
| 145 | Name: it.String(), |
| 146 | Type: reflect.TypeOf(it).String(), |
| 147 | Size: sz, Exact: exact, |
| 148 | } |
| 149 | if tg, ok := it.(Tagger); ok { |
| 150 | d.Tags = tg.Tags() |
| 151 | } |
| 152 | if sub := it.SubIterators(); len(sub) != 0 { |
| 153 | d.Iterators = make([]Description, 0, len(sub)) |
| 154 | for _, sit := range sub { |
| 155 | d.Iterators = append(d.Iterators, DescribeIterator(sit)) |
| 156 | } |
| 157 | } |
| 158 | return d |
| 159 | } |
| 160 | |
| 161 | type Description struct { |
| 162 | UID uint64 `json:",omitempty"` |