1
0
mirror of https://github.com/jhillyerd/inbucket.git synced 2025-12-17 17:47:03 +00:00
Files
go-inbucket/pkg/storage/storage.go
James Hillyerd e84b1f8952 storage: Make locking an implementation detail for #69
- file: Store handles its own locking #77
- file: Move mbox into its own file
- file & test: remove LockFor()
2018-03-17 14:02:50 -07:00

41 lines
1.1 KiB
Go

// Package storage contains implementation independent datastore logic
package storage
import (
"errors"
"io"
"net/mail"
"time"
)
var (
// ErrNotExist indicates the requested message does not exist.
ErrNotExist = errors.New("message does not exist")
// ErrNotWritable indicates the message is closed; no longer writable
ErrNotWritable = errors.New("Message not writable")
)
// Store is the interface Inbucket uses to interact with storage implementations.
type Store interface {
// AddMessage stores the message, message ID and Size will be ignored.
AddMessage(message StoreMessage) (id string, err error)
GetMessage(mailbox, id string) (StoreMessage, error)
GetMessages(mailbox string) ([]StoreMessage, error)
PurgeMessages(mailbox string) error
RemoveMessage(mailbox, id string) error
VisitMailboxes(f func([]StoreMessage) (cont bool)) error
}
// StoreMessage represents a message to be stored, or returned from a storage implementation.
type StoreMessage interface {
Mailbox() string
ID() string
From() *mail.Address
To() []*mail.Address
Date() time.Time
Subject() string
RawReader() (reader io.ReadCloser, err error)
Size() int64
}