Debian Codegraph @

worker/jmap/cache/mailbox_list.go

raw
1 package cache
2
3 import (
4 "git.sr.ht/~rockorager/go-jmap"
5 )
6
7 type IDList struct {
8 IDs []jmap.ID
9 }
10
11 func (c *JMAPCache) GetMailboxList() ([]jmap.ID, error) {
12 buf, err := c.get(mailboxListKey)
13 if err != nil {
14 return nil, err
15 }
16 var list IDList
17 err = unmarshal(buf, &list)
18 if err != nil {
19 return nil, err
20 }
21 return list.IDs, nil
22 }
23
24 func (c *JMAPCache) PutMailboxList(list []jmap.ID) error {
25 buf, err := marshal(&IDList{IDs: list})
26 if err != nil {
27 return err
28 }
29 return c.put(mailboxListKey, buf)
30 }
31
32 const mailboxListKey = "mailbox/list"