mirror of
https://github.com/jhillyerd/inbucket.git
synced 2025-12-17 17:47:03 +00:00
mem: Initial in-memory store implementation for #88
- Reduce default retention sleep, change description.
This commit is contained in:
51
pkg/storage/mem/message.go
Normal file
51
pkg/storage/mem/message.go
Normal file
@@ -0,0 +1,51 @@
|
||||
package mem
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/mail"
|
||||
"time"
|
||||
|
||||
"github.com/jhillyerd/inbucket/pkg/storage"
|
||||
)
|
||||
|
||||
// Message is a memory store message.
|
||||
type Message struct {
|
||||
index int
|
||||
mailbox string
|
||||
id string
|
||||
from *mail.Address
|
||||
to []*mail.Address
|
||||
date time.Time
|
||||
subject string
|
||||
source []byte
|
||||
}
|
||||
|
||||
var _ storage.Message = &Message{}
|
||||
|
||||
// Mailbox returns the mailbox name.
|
||||
func (m *Message) Mailbox() string { return m.mailbox }
|
||||
|
||||
// ID the message ID.
|
||||
func (m *Message) ID() string { return m.id }
|
||||
|
||||
// From returns the from address.
|
||||
func (m *Message) From() *mail.Address { return m.from }
|
||||
|
||||
// To returns the to address list.
|
||||
func (m *Message) To() []*mail.Address { return m.to }
|
||||
|
||||
// Date returns the date received.
|
||||
func (m *Message) Date() time.Time { return m.date }
|
||||
|
||||
// Subject returns the subject line.
|
||||
func (m *Message) Subject() string { return m.subject }
|
||||
|
||||
// Source returns a reader for the message source.
|
||||
func (m *Message) Source() (io.ReadCloser, error) {
|
||||
return ioutil.NopCloser(bytes.NewReader(m.source)), nil
|
||||
}
|
||||
|
||||
// Size returns the message size in bytes.
|
||||
func (m *Message) Size() int64 { return int64(len(m.source)) }
|
||||
Reference in New Issue
Block a user