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
|
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:
|
2016-05-04 11:26:36 +00:00
|
|
|
return "readwrite"
|
2016-12-16 22:23:35 +00:00
|
|
|
case FolderTypeSendOnly:
|
2016-05-04 11:26:36 +00:00
|
|
|
return "readonly"
|
|
|
|
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
|
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
|
|
|
|
}
|