types.go 762 B

123456789101112131415161718192021222324252627282930313233343536
  1. // Copyright (C) 2016 The Syncthing Authors.
  2. //
  3. // This Source Code Form is subject to the terms of the Mozilla Public
  4. // License, v. 2.0. If a copy of the MPL was not distributed with this file,
  5. // You can obtain one at https://mozilla.org/MPL/2.0/.
  6. package fs
  7. type FilesystemType int
  8. const (
  9. FilesystemTypeBasic FilesystemType = iota // default is basic
  10. )
  11. func (t FilesystemType) String() string {
  12. switch t {
  13. case FilesystemTypeBasic:
  14. return "basic"
  15. default:
  16. return "unknown"
  17. }
  18. }
  19. func (t FilesystemType) MarshalText() ([]byte, error) {
  20. return []byte(t.String()), nil
  21. }
  22. func (t *FilesystemType) UnmarshalText(bs []byte) error {
  23. switch string(bs) {
  24. case "basic":
  25. *t = FilesystemTypeBasic
  26. default:
  27. *t = FilesystemTypeBasic
  28. }
  29. return nil
  30. }