header

package
v0.8.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 28, 2023 License: BSD-2-Clause Imports: 9 Imported by: 0

Documentation

Overview

Package header has structs and functions handling with mail header and their modifications

Index

Constants

View Source
const (
	KindEqual = iota
	KindChange
	KindInsert
)

Variables

This section is empty.

Functions

func Diff

func Diff(orig *Header, changed *Header) (changeInsertOps []Op, addOps []Op)

Diff finds differences between orig and changed. The differences are expressed as change and insert operations – to be mapped to milter modification actions. Deletions are changes to an empty value.

func DiffOrRecreate added in v0.8.2

func DiffOrRecreate(recreate bool, orig *Header, changed *Header) (changeInsertOps []Op, addOps []Op)

DiffOrRecreate is a convenience method that either calls Diff or Recreate

func Recreate added in v0.8.2

func Recreate(orig *Header, changed *Header) (changeInsertOps []Op, addOps []Op)

Recreate deletes all headers of orig and adds all headers of changed.

Types

type Field

type Field struct {
	Index        int
	CanonicalKey string
	Raw          []byte
}

func (*Field) Deleted

func (f *Field) Deleted() bool

func (*Field) Key

func (f *Field) Key() string

func (*Field) UnfoldedValue added in v0.8.1

func (f *Field) UnfoldedValue() string

func (*Field) Value

func (f *Field) Value() string

type Fields

type Fields struct {
	// contains filtered or unexported fields
}

func (*Fields) AddressList

func (f *Fields) AddressList() ([]*mail.Address, error)

func (*Fields) CanonicalKey

func (f *Fields) CanonicalKey() string

func (*Fields) Del

func (f *Fields) Del()

func (*Fields) InsertAddressListAfter

func (f *Fields) InsertAddressListAfter(key string, value []*mail.Address)

func (*Fields) InsertAddressListBefore

func (f *Fields) InsertAddressListBefore(key string, value []*mail.Address)

func (*Fields) InsertAfter

func (f *Fields) InsertAfter(key string, value string)

func (*Fields) InsertBefore

func (f *Fields) InsertBefore(key string, value string)

func (*Fields) InsertTextAfter

func (f *Fields) InsertTextAfter(key string, value string)

func (*Fields) InsertTextBefore

func (f *Fields) InsertTextBefore(key string, value string)

func (*Fields) IsDeleted

func (f *Fields) IsDeleted() bool

IsDeleted returns true when a previous header modification deleted this header. You can "undelete" the header by just calling [HeaderFields.Set] with a non-empty value.

func (*Fields) Key

func (f *Fields) Key() string

func (*Fields) Len

func (f *Fields) Len() int

Len returns the number of fields in the header. This also includes deleted headers fields. Initially no fields are deleted so Len returns the actual number of header fields.

func (*Fields) Next

func (f *Fields) Next() bool

func (*Fields) Raw

func (f *Fields) Raw() []byte

func (*Fields) Replace

func (f *Fields) Replace(key string, value string)

func (*Fields) ReplaceAddressList

func (f *Fields) ReplaceAddressList(key string, value []*mail.Address)

func (*Fields) ReplaceText

func (f *Fields) ReplaceText(key string, value string)

func (*Fields) Set

func (f *Fields) Set(value string)

func (*Fields) SetAddressList

func (f *Fields) SetAddressList(value []*mail.Address)

func (*Fields) SetText

func (f *Fields) SetText(value string)

func (*Fields) Text

func (f *Fields) Text() (string, error)

func (*Fields) UnfoldedValue added in v0.8.1

func (f *Fields) UnfoldedValue() string

func (*Fields) Value

func (f *Fields) Value() string
type Header struct {
	// contains filtered or unexported fields
}

func New

func New(raw []byte) (*Header, error)

func (*Header) Add

func (h *Header) Add(key string, value string)

func (*Header) AddRaw

func (h *Header) AddRaw(key string, raw []byte)

func (*Header) AddressList

func (h *Header) AddressList(key string) ([]*mail.Address, error)

func (*Header) Copy

func (h *Header) Copy() *Header

func (*Header) Date

func (h *Header) Date() (time.Time, error)

func (*Header) Fields

func (h *Header) Fields() header.Fields

func (*Header) Reader

func (h *Header) Reader() io.Reader

func (*Header) Set

func (h *Header) Set(key string, value string)

func (*Header) SetAddressList

func (h *Header) SetAddressList(key string, addresses []*mail.Address)

func (*Header) SetDate

func (h *Header) SetDate(value time.Time)

SetDate sets the Date header to the value. The zero value of time.Time as valid. This will delete the Date header when it exists.

func (*Header) SetSubject

func (h *Header) SetSubject(value string)

func (*Header) SetText

func (h *Header) SetText(key string, value string)

func (*Header) Subject

func (h *Header) Subject() (string, error)

func (*Header) Text

func (h *Header) Text(key string) (string, error)

func (*Header) UnfoldedValue added in v0.8.1

func (h *Header) UnfoldedValue(key string) string

func (*Header) Value

func (h *Header) Value(key string) string

type Op

type Op struct {
	Kind  int
	Index int
	Name  string
	Value string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL