aboutsummaryrefslogtreecommitdiff
path: root/vendor/maunium.net/go/mautrix/store.go
diff options
context:
space:
mode:
authorTulir Asokan <tulir@maunium.net>2019-01-11 23:28:47 +0200
committerTulir Asokan <tulir@maunium.net>2019-01-11 23:28:47 +0200
commit331597b9f8a7942cbcb233a328301e4d5bf94fb0 (patch)
tree5ec624585ebf66c63549a098acb6f7421f1193a7 /vendor/maunium.net/go/mautrix/store.go
parent2fc3378b717f40f37f3a188b68407887242d9c06 (diff)
Switch to Go modules and make other changes
Diffstat (limited to 'vendor/maunium.net/go/mautrix/store.go')
-rw-r--r--vendor/maunium.net/go/mautrix/store.go65
1 files changed, 0 insertions, 65 deletions
diff --git a/vendor/maunium.net/go/mautrix/store.go b/vendor/maunium.net/go/mautrix/store.go
deleted file mode 100644
index 774398e..0000000
--- a/vendor/maunium.net/go/mautrix/store.go
+++ /dev/null
@@ -1,65 +0,0 @@
-package mautrix
-
-// Storer is an interface which must be satisfied to store client data.
-//
-// You can either write a struct which persists this data to disk, or you can use the
-// provided "InMemoryStore" which just keeps data around in-memory which is lost on
-// restarts.
-type Storer interface {
- SaveFilterID(userID, filterID string)
- LoadFilterID(userID string) string
- SaveNextBatch(userID, nextBatchToken string)
- LoadNextBatch(userID string) string
- SaveRoom(room *Room)
- LoadRoom(roomID string) *Room
-}
-
-// InMemoryStore implements the Storer interface.
-//
-// Everything is persisted in-memory as maps. It is not safe to load/save filter IDs
-// or next batch tokens on any goroutine other than the syncing goroutine: the one
-// which called Client.Sync().
-type InMemoryStore struct {
- Filters map[string]string
- NextBatch map[string]string
- Rooms map[string]*Room
-}
-
-// SaveFilterID to memory.
-func (s *InMemoryStore) SaveFilterID(userID, filterID string) {
- s.Filters[userID] = filterID
-}
-
-// LoadFilterID from memory.
-func (s *InMemoryStore) LoadFilterID(userID string) string {
- return s.Filters[userID]
-}
-
-// SaveNextBatch to memory.
-func (s *InMemoryStore) SaveNextBatch(userID, nextBatchToken string) {
- s.NextBatch[userID] = nextBatchToken
-}
-
-// LoadNextBatch from memory.
-func (s *InMemoryStore) LoadNextBatch(userID string) string {
- return s.NextBatch[userID]
-}
-
-// SaveRoom to memory.
-func (s *InMemoryStore) SaveRoom(room *Room) {
- s.Rooms[room.ID] = room
-}
-
-// LoadRoom from memory.
-func (s *InMemoryStore) LoadRoom(roomID string) *Room {
- return s.Rooms[roomID]
-}
-
-// NewInMemoryStore constructs a new InMemoryStore.
-func NewInMemoryStore() *InMemoryStore {
- return &InMemoryStore{
- Filters: make(map[string]string),
- NextBatch: make(map[string]string),
- Rooms: make(map[string]*Room),
- }
-}