Skip to content

Commit

Permalink
added some drive enum stringer methods.
Browse files Browse the repository at this point in the history
  • Loading branch information
xmichelo committed Mar 17, 2024
1 parent b0e348b commit 2ee380c
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 1 deletion.
41 changes: 40 additions & 1 deletion share_types.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package proton

import "github.com/ProtonMail/gopenpgp/v2/crypto"
import (
"fmt"

"github.com/ProtonMail/gopenpgp/v2/crypto"
)

type ShareMetadata struct {
ShareID string // Encrypted share ID
Expand Down Expand Up @@ -76,16 +80,51 @@ const (
ShareTypeDevice ShareType = 3
)

func (t ShareType) String() string {
switch t {
case ShareTypeMain:
return "main"
case ShareTypeStandard:
return "standard"
case ShareTypeDevice:
return "device"
default:
return fmt.Sprintf("unknown (%v)", int(t))
}
}

type ShareState int

const (
ShareStateActive ShareState = 1
ShareStateDeleted ShareState = 2
)

func (s ShareState) String() string {
switch s {
case ShareStateActive:
return "active"
case ShareStateDeleted:
return "deleted"
default:
return fmt.Sprintf("unknown (%v)", int(s))
}
}

type ShareFlags int

const (
NoFlags ShareFlags = iota
PrimaryShare
)

func (f ShareFlags) String() string {
switch f {
case NoFlags:
return "none"
case PrimaryShare:
return "primary"
default:
return fmt.Sprintf("unknown (%v)", int(f))
}
}
26 changes: 26 additions & 0 deletions volume_types.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package proton

import "fmt"

// Volume is a Proton Drive volume.
type Volume struct {
VolumeID string // Encrypted volume ID
Expand Down Expand Up @@ -30,6 +32,17 @@ const (
VolumeStateLocked VolumeState = 3
)

func (v VolumeState) String() string {
switch v {
case VolumeStateActive:
return "active"
case VolumeStateLocked:
return "locked"
default:
return fmt.Sprintf("unknown (%v)", int(v))
}
}

// VolumeRestoreStatus is the status of the restore task.
type VolumeRestoreStatus int

Expand All @@ -38,3 +51,16 @@ const (
RestoreStatusInProgress VolumeRestoreStatus = 1
RestoreStatusFailed VolumeRestoreStatus = -1
)

func (rs VolumeRestoreStatus) String() string {
switch rs {
case RestoreStatusDone:
return "done"
case RestoreStatusInProgress:
return "in progress"
case RestoreStatusFailed:
return "failed"
default:
return fmt.Sprintf("unknown (%v)", int(rs))
}
}

0 comments on commit 2ee380c

Please sign in to comment.