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