devices

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2023 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Overview

Package devices implements operations for device data manipulation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Add added in v0.5.0

func Add(ctx context.Context, args AddDeviceRequest) (string, error)

Add adds new Device to given storage with default options. Returns assigned ID if there is no error.

func Filter

func Filter(d []models.Device, f func(models.Device) bool) []models.Device

func PublicSlice

func PublicSlice(d []models.Device) []models.DevicePublicData

PublicSlice returns new slice with only public device data, created from given slice containing full device data.

func Update

func Update(old models.Device, c *Changes) models.Device

Update applies given changes to given device model and returns new device model.

Types

type AddDeviceRequest added in v0.5.0

type AddDeviceRequest struct {
	// OwnerID is id of user that owns new device.
	OwnerID string

	// Owner is nickname of new device owner.
	Owner string

	// Tag is a name for new device.
	Tag string

	// MAC is raw hardress address of the device.
	//
	// There is no need to verify MAC before passing to
	// AddDeviceRequest, because it will be verified during
	// adding to storage by Add function.
	MAC string

	// Storage for devices.
	Storage storage.Devices
}

AddDeviceRequest holds arguments for Add service method.

type Changes

type Changes struct {
	MAC []byte
	Tag string
}

Changes represents possible changes that can be applied to models.Device

Jump to

Keyboard shortcuts

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