inmemstore

package
v0.0.0-...-3008a97 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2022 License: MPL-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrDeviceIDMustBeSet = errors.New("device JID must be known before accessing database")

ErrDeviceIDMustBeSet is the error returned by PutDevice if you try to save a device before knowing its JID.

Functions

This section is empty.

Types

type Container

type Container struct {
	// contains filtered or unexported fields
}

func New

func New(log waLog.Logger) *Container

New creates a new in-memory store container.

The logger can be nil and will default to a no-op logger.

container := inmemstore.New(nil)

func (*Container) DeleteDevice

func (c *Container) DeleteDevice(store *store.Device) error

DeleteDevice deletes the given device from this database. This should be called through Device.Delete()

func (*Container) GetAllDevices

func (c *Container) GetAllDevices() []*store.Device

GetAllDevices return all devices from devices array.

func (*Container) GetDevice

func (c *Container) GetDevice(jid types.JID) (*store.Device, error)

GetDevice finds the device with the specified JID in the device array.

If the device is not found, nil is returned instead.

Note that the parameter usually must be an AD-JID.

func (*Container) GetFirstDevice

func (c *Container) GetFirstDevice() (*store.Device, error)

GetFirstDevice is a convenience method for getting the first device in device array. If there are no devices, then a new device will be created. You should only use this if you don't want to have multiple sessions simultaneously.

func (*Container) NewDevice

func (c *Container) NewDevice() *store.Device

NewDevice creates a new device in this database.

No data is actually stored before Save is called. However, the pairing process will automatically call Save after a successful pairing, so you most likely don't need to call it yourself.

func (*Container) PutDevice

func (c *Container) PutDevice(device *store.Device) error

PutDevice stores the given device in this database. This should be called through Device.Save() (which usually doesn't need to be called manually, as the library does that automatically when relevant). in this package this would be ignored, instead we let the package users save it in their own way.

Jump to

Keyboard shortcuts

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