2016-05-04 11:26:36 +00:00
|
|
|
// Copyright (C) 2016 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/.
|
2016-05-04 11:26:36 +00:00
|
|
|
|
|
|
|
package config
|
|
|
|
|
|
|
|
type FolderType int
|
|
|
|
|
|
|
|
const (
|
2016-12-16 22:23:35 +00:00
|
|
|
FolderTypeSendReceive FolderType = iota // default is sendreceive
|
|
|
|
FolderTypeSendOnly
|
2018-07-12 08:15:57 +00:00
|
|
|
FolderTypeReceiveOnly
|
2016-05-04 11:26:36 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func (t FolderType) String() string {
|
|
|
|
switch t {
|
2016-12-16 22:23:35 +00:00
|
|
|
case FolderTypeSendReceive:
|
2018-05-13 07:58:00 +00:00
|
|
|
return "sendreceive"
|
2016-12-16 22:23:35 +00:00
|
|
|
case FolderTypeSendOnly:
|
2018-05-13 07:58:00 +00:00
|
|
|
return "sendonly"
|
2018-07-12 08:15:57 +00:00
|
|
|
case FolderTypeReceiveOnly:
|
|
|
|
return "receiveonly"
|
2016-05-04 11:26:36 +00:00
|
|
|
default:
|
|
|
|
return "unknown"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t FolderType) MarshalText() ([]byte, error) {
|
|
|
|
return []byte(t.String()), nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *FolderType) UnmarshalText(bs []byte) error {
|
|
|
|
switch string(bs) {
|
2016-12-16 22:23:35 +00:00
|
|
|
case "readwrite", "sendreceive":
|
|
|
|
*t = FolderTypeSendReceive
|
|
|
|
case "readonly", "sendonly":
|
|
|
|
*t = FolderTypeSendOnly
|
2018-07-12 08:15:57 +00:00
|
|
|
case "receiveonly":
|
|
|
|
*t = FolderTypeReceiveOnly
|
2016-05-04 11:26:36 +00:00
|
|
|
default:
|
2016-12-16 22:23:35 +00:00
|
|
|
*t = FolderTypeSendReceive
|
2016-05-04 11:26:36 +00:00
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|