identity

package
v0.0.0-...-976fe2d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 30, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DeviceInfo

type DeviceInfo struct {
	DeviceInfoFile string
	Config         Identity

	Logger *logrus.Logger
	// contains filtered or unexported fields
}

DeviceInfo manages the device identity and its associated file operations.

func (*DeviceInfo) GetDeviceID

func (d *DeviceInfo) GetDeviceID() string

GetDeviceID returns the current device ID from the Config field.

func (*DeviceInfo) LoadDeviceInfo

func (d *DeviceInfo) LoadDeviceInfo() error

LoadDeviceInfo reads the device information from the file and populates the Config field. If the file does not exist or is empty, it initializes the Config to default (empty) values.

func (*DeviceInfo) SaveDeviceID

func (d *DeviceInfo) SaveDeviceID(deviceID string) error

SaveDeviceID updates the device ID in the Config field and writes it back to the file. Returns an error if marshalling the Config or writing the file fails.

type DeviceInfoInterface

type DeviceInfoInterface interface {
	LoadDeviceInfo() error
	GetDeviceID() string
	SaveDeviceID(deviceID string) error
}

DeviceInfoInterface defines the methods that DeviceInfo implements

func NewDeviceInfo

func NewDeviceInfo(filePath string, fileOps file.FileOperations, logger *logrus.Logger) DeviceInfoInterface

NewDeviceInfo initializes a new DeviceInfo instance with the specified file path and file operations. Returns a pointer to a DeviceInfo instance with the file path and file operations set.

type Identity

type Identity struct {
	ID string `json:"device_id"`
}

Identity holds the device's unique identifier.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL