diff options
Diffstat (limited to 'main/pathfilter.go')
-rw-r--r-- | main/pathfilter.go | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/main/pathfilter.go b/main/pathfilter.go index 7e21efe..1af3b6d 100644 --- a/main/pathfilter.go +++ b/main/pathfilter.go @@ -1,9 +1,13 @@ package main +import ( + "main/walk" +) + type AnySegmentPathFilter struct { next PathFilterState } -func (filter AnySegmentPathFilter) eat(segment PathSegment) map[PathFilterState]struct{} { +func (filter AnySegmentPathFilter) eat(segment walk.PathSegment) map[PathFilterState]struct{} { res := make(map[PathFilterState]struct{}) res[filter.next] = struct{}{} return res @@ -15,7 +19,7 @@ func (filter AnySegmentPathFilter) accept() bool { type OrPathFilter struct { filters [2]PathFilterState } -func (filter OrPathFilter) eat(segment PathSegment) map[PathFilterState]struct{} { +func (filter OrPathFilter) eat(segment walk.PathSegment) map[PathFilterState]struct{} { res := make(map[PathFilterState]struct{}) for _, f := range filter.filters { for r := range f.eat(segment) { @@ -34,7 +38,7 @@ func (filter OrPathFilter) accept() bool { } type NonePathFilter struct {} -func (filter NonePathFilter) eat(segment PathSegment) map[PathFilterState]struct{} { +func (filter NonePathFilter) eat(segment walk.PathSegment) map[PathFilterState]struct{} { return make(map[PathFilterState]struct{}) } func (filter NonePathFilter) accept() bool { @@ -45,7 +49,7 @@ type StringSegmentPathFilter struct { index string next PathFilterState } -func (filter StringSegmentPathFilter) eat(segment PathSegment) map[PathFilterState]struct{} { +func (filter StringSegmentPathFilter) eat(segment walk.PathSegment) map[PathFilterState]struct{} { s, isString := segment.(string) res := make(map[PathFilterState]struct{}) if isString && s == filter.index { @@ -61,7 +65,7 @@ type IntegerSegmentPathFilter struct { index int next PathFilterState } -func (filter IntegerSegmentPathFilter) eat(segment PathSegment) map[PathFilterState]struct{} { +func (filter IntegerSegmentPathFilter) eat(segment walk.PathSegment) map[PathFilterState]struct{} { i, isInteger := segment.(int) res := make(map[PathFilterState]struct{}) if isInteger && i == filter.index { @@ -74,6 +78,6 @@ func (filter IntegerSegmentPathFilter) accept() bool { } type PathFilterState interface { - eat(PathSegment) map[PathFilterState]struct{} + eat(walk.PathSegment) map[PathFilterState]struct{} accept() bool } |