2016-05-04 13:26:36 +02: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 07:52:18 +01:00
|
|
|
// You can obtain one at https://mozilla.org/MPL/2.0/.
|
2016-05-04 13:26:36 +02:00
|
|
|
|
|
|
|
package config
|
|
|
|
|
|
|
|
func (t FolderType) String() string {
|
|
|
|
switch t {
|
2016-12-16 23:23:35 +01:00
|
|
|
case FolderTypeSendReceive:
|
2018-05-13 09:58:00 +02:00
|
|
|
return "sendreceive"
|
2016-12-16 23:23:35 +01:00
|
|
|
case FolderTypeSendOnly:
|
2018-05-13 09:58:00 +02:00
|
|
|
return "sendonly"
|
2018-07-12 10:15:57 +02:00
|
|
|
case FolderTypeReceiveOnly:
|
|
|
|
return "receiveonly"
|
2016-05-04 13:26:36 +02: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 23:23:35 +01:00
|
|
|
case "readwrite", "sendreceive":
|
|
|
|
*t = FolderTypeSendReceive
|
|
|
|
case "readonly", "sendonly":
|
|
|
|
*t = FolderTypeSendOnly
|
2018-07-12 10:15:57 +02:00
|
|
|
case "receiveonly":
|
|
|
|
*t = FolderTypeReceiveOnly
|
2016-05-04 13:26:36 +02:00
|
|
|
default:
|
2016-12-16 23:23:35 +01:00
|
|
|
*t = FolderTypeSendReceive
|
2016-05-04 13:26:36 +02:00
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|