2015-10-27 10:37:03 +00:00
|
|
|
// Copyright (C) 2014 The Syncthing Authors.
|
|
|
|
//
|
|
|
|
// This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
2017-02-09 06:52:18 +00:00
|
|
|
// You can obtain one at https://mozilla.org/MPL/2.0/.
|
2015-10-27 10:37:03 +00:00
|
|
|
|
|
|
|
package config
|
|
|
|
|
|
|
|
func (o PullOrder) String() string {
|
|
|
|
switch o {
|
2020-08-25 06:11:14 +00:00
|
|
|
case PullOrderRandom:
|
2015-10-27 10:37:03 +00:00
|
|
|
return "random"
|
2020-08-25 06:11:14 +00:00
|
|
|
case PullOrderAlphabetic:
|
2015-10-27 10:37:03 +00:00
|
|
|
return "alphabetic"
|
2020-08-25 06:11:14 +00:00
|
|
|
case PullOrderSmallestFirst:
|
2015-10-27 10:37:03 +00:00
|
|
|
return "smallestFirst"
|
2020-08-25 06:11:14 +00:00
|
|
|
case PullOrderLargestFirst:
|
2015-10-27 10:37:03 +00:00
|
|
|
return "largestFirst"
|
2020-08-25 06:11:14 +00:00
|
|
|
case PullOrderOldestFirst:
|
2015-10-27 10:37:03 +00:00
|
|
|
return "oldestFirst"
|
2020-08-25 06:11:14 +00:00
|
|
|
case PullOrderNewestFirst:
|
2015-10-27 10:37:03 +00:00
|
|
|
return "newestFirst"
|
|
|
|
default:
|
|
|
|
return "unknown"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (o PullOrder) MarshalText() ([]byte, error) {
|
|
|
|
return []byte(o.String()), nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (o *PullOrder) UnmarshalText(bs []byte) error {
|
|
|
|
switch string(bs) {
|
|
|
|
case "random":
|
2020-08-25 06:11:14 +00:00
|
|
|
*o = PullOrderRandom
|
2015-10-27 10:37:03 +00:00
|
|
|
case "alphabetic":
|
2020-08-25 06:11:14 +00:00
|
|
|
*o = PullOrderAlphabetic
|
2015-10-27 10:37:03 +00:00
|
|
|
case "smallestFirst":
|
2020-08-25 06:11:14 +00:00
|
|
|
*o = PullOrderSmallestFirst
|
2015-10-27 10:37:03 +00:00
|
|
|
case "largestFirst":
|
2020-08-25 06:11:14 +00:00
|
|
|
*o = PullOrderLargestFirst
|
2015-10-27 10:37:03 +00:00
|
|
|
case "oldestFirst":
|
2020-08-25 06:11:14 +00:00
|
|
|
*o = PullOrderOldestFirst
|
2015-10-27 10:37:03 +00:00
|
|
|
case "newestFirst":
|
2020-08-25 06:11:14 +00:00
|
|
|
*o = PullOrderNewestFirst
|
2015-10-27 10:37:03 +00:00
|
|
|
default:
|
2020-08-25 06:11:14 +00:00
|
|
|
*o = PullOrderRandom
|
2015-10-27 10:37:03 +00:00
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|