-
Notifications
You must be signed in to change notification settings - Fork 0
/
storage.go
35 lines (28 loc) · 901 Bytes
/
storage.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package ns
type StorageType interface {
isStorageType()
}
// Session is a game session storage with a given name. It will persist as long as a single game session runs.
type Session struct {
Name string
}
func (Session) isStorageType() {}
// Persistent returns a persistent storage with a given name. It will persist between OpenNox restarts.
type Persistent struct {
Name string
}
func (Persistent) isStorageType() {}
// Store returns a global storage with a given type.
func Store(typ StorageType) Storage {
if impl == nil {
return nil
}
return impl.Store(typ)
}
type Storage interface {
// Get fetches a custom object or value from the storage with a given key.
// Argument must be a pointer to a value of the same type as used during Set.
Get(key string, obj any) error
// Set stores a custom object or value into the storage with a given key.
Set(key string, obj any) error
}