| 104 | } |
| 105 | |
| 106 | func (this *Table) AddSet(name string, options *SetOptions) (*Set, error) { |
| 107 | if len(name) > MaxSetNameLength { |
| 108 | return nil, errors.New("set name too long (max " + types.String(MaxSetNameLength) + ")") |
| 109 | } |
| 110 | |
| 111 | if options == nil { |
| 112 | options = &SetOptions{} |
| 113 | } |
| 114 | var rawSet = &nft.Set{ |
| 115 | Table: this.rawTable, |
| 116 | ID: options.Id, |
| 117 | Name: name, |
| 118 | Anonymous: options.Anonymous, |
| 119 | Constant: options.Constant, |
| 120 | Interval: options.Interval, |
| 121 | IsMap: options.IsMap, |
| 122 | HasTimeout: options.HasTimeout, |
| 123 | Timeout: options.Timeout, |
| 124 | KeyType: options.KeyType, |
| 125 | DataType: options.DataType, |
| 126 | } |
| 127 | err := this.conn.Raw().AddSet(rawSet, nil) |
| 128 | if err != nil { |
| 129 | return nil, err |
| 130 | } |
| 131 | |
| 132 | err = this.conn.Commit() |
| 133 | if err != nil { |
| 134 | return nil, err |
| 135 | } |
| 136 | |
| 137 | return NewSet(this.conn, rawSet), nil |
| 138 | } |
| 139 | |
| 140 | func (this *Table) DeleteSet(name string) error { |
| 141 | set, err := this.GetSet(name) |