blob: 443887785e957009f3e16d1d5b535fd3f989795a (
plain) (
blame)
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 cache
import (
"git.sr.ht/~rockorager/go-jmap"
"git.sr.ht/~rockorager/go-jmap/mail/mailbox"
)
func (c *JMAPCache) GetMailbox(id jmap.ID) (*mailbox.Mailbox, error) {
buf, err := c.get(mailboxKey(id))
if err != nil {
return nil, err
}
m := new(mailbox.Mailbox)
err = unmarshal(buf, m)
if err != nil {
return nil, err
}
return m, nil
}
func (c *JMAPCache) PutMailbox(id jmap.ID, m *mailbox.Mailbox) error {
buf, err := marshal(m)
if err != nil {
return err
}
return c.put(mailboxKey(id), buf)
}
func (c *JMAPCache) DeleteMailbox(id jmap.ID) error {
return c.delete(mailboxKey(id))
}
func mailboxKey(id jmap.ID) string {
return "mailbox/" + string(id)
}
|