github.com/database64128/shadowsocks-go@v1.10.2-0.20240315062903-143a773533f1/domainset/matcher.go (about) 1 package domainset 2 3 // Matcher provides the Match method. 4 type Matcher interface { 5 // Match returns whether the domain is matched by the matcher. 6 Match(domain string) bool 7 } 8 9 // MatcherBuilder provides methods for building a [Matcher]. 10 type MatcherBuilder interface { 11 // Insert inserts the rule string to the matcher. 12 // 13 // The rule string must not include the rule identifier. 14 // For example, if the rule line is "suffix:google.com", 15 // the rule string should be "google.com". 16 Insert(rule string) 17 18 // Rules returns the inserted rules as a slice. 19 Rules() []string 20 21 // MatcherCount returns the number of matchers that would be appended 22 // to the matcher slice by calling [AppendTo]. 23 MatcherCount() int 24 25 // AppendTo builds the matcher, appends the matcher to the matcher slice, 26 // and returns the updated slice or an error. 27 AppendTo(matchers []Matcher) ([]Matcher, error) 28 }