-
Notifications
You must be signed in to change notification settings - Fork 390
/
operator.go
37 lines (30 loc) · 890 Bytes
/
operator.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Copyright (C) 2021 Storj Labs, Inc.
// See LICENSE for copying information.
package compensation
import "strings"
// WalletFeatures represents wallet features list.
type WalletFeatures []string
// DecodeWalletFeatures decodes wallet features list string separated by "|".
func DecodeWalletFeatures(s string) (WalletFeatures, error) {
if s == "" {
return nil, nil
}
return strings.Split(s, "|"), nil
}
// String outputs .
func (features WalletFeatures) String() string {
return strings.Join(features, "|")
}
// UnmarshalCSV reads the WalletFeatures in CSV form.
func (features *WalletFeatures) UnmarshalCSV(s string) error {
v, err := DecodeWalletFeatures(s)
if err != nil {
return err
}
*features = v
return nil
}
// MarshalCSV returns the CSV form of the WalletFeatures.
func (features WalletFeatures) MarshalCSV() (string, error) {
return features.String(), nil
}