Documentation ¶
Index ¶
- Variables
- type Container
- func (c *Container) DeleteDevice(store *store.Device) error
- func (c *Container) GetAllDevices() []*store.Device
- func (c *Container) GetDevice(jid types.JID) (*store.Device, error)
- func (c *Container) GetFirstDevice() (*store.Device, error)
- func (c *Container) NewDevice() *store.Device
- func (c *Container) PutDevice(device *store.Device) error
Constants ¶
This section is empty.
Variables ¶
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 ¶
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 ¶
DeleteDevice deletes the given device from this database. This should be called through Device.Delete()
func (*Container) GetAllDevices ¶
GetAllDevices return all devices from devices array.
func (*Container) GetDevice ¶
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 ¶
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 ¶
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 ¶
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.