parser

package
v1.8.11 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2021 License: GPL-3.0 Imports: 14 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HandlerFunc

type HandlerFunc func(*Part) error

type Parser

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

func New

func New(r io.Reader) (*Parser, error)

func (*Parser) NewVisitor

func (p *Parser) NewVisitor(defaultRule VisitorRule) *Visitor

func (*Parser) NewWalker

func (p *Parser) NewWalker() *Walker

func (*Parser) NewWriter

func (p *Parser) NewWriter() *Writer

func (*Parser) Root

func (p *Parser) Root() *Part

func (*Parser) Section

func (p *Parser) Section(section []int) (part *Part, err error)

Section returns the message part referred to by the given section. A section is zero or more integers. For example, section 1.2.3 will return the third part of the second part of the first part of the message.

type Part

type Part struct {
	Header message.Header
	Body   []byte
	// contains filtered or unexported fields
}

func (*Part) AddChild

func (p *Part) AddChild(child *Part)

func (*Part) Child

func (p *Part) Child(n int) (part *Part, err error)

func (*Part) Children

func (p *Part) Children() Parts

func (*Part) ContentType

func (p *Part) ContentType() (string, map[string]string, error)

func (*Part) ConvertMetaCharset

func (p *Part) ConvertMetaCharset() error

func (*Part) ConvertToUTF8

func (p *Part) ConvertToUTF8() error

type Parts

type Parts []*Part

type Visit

type Visit func(*Part) (interface{}, error)

type Visitor

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

func (*Visitor) RegisterRule

func (v *Visitor) RegisterRule(contentTypeRegex string, fn VisitorRule) *Visitor

RegisterRule defines what to do when visiting a part whose content type matches the given regular expression. If a part matches multiple rules, the one registered first will be used.

func (*Visitor) Visit

func (v *Visitor) Visit() (interface{}, error)

type VisitorRule

type VisitorRule func(*Part, Visit) (interface{}, error)

type Walker

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

func (*Walker) RegisterContentDispositionHandler

func (w *Walker) RegisterContentDispositionHandler(dispRegExp string, fn HandlerFunc) *Walker

RegisterContentDispositionHandler registers a handler that will be called when a part's content disposition matches the given regular expression. If a part matches multiple handlers, the one registered first will be chosen.

func (*Walker) RegisterContentTypeHandler

func (w *Walker) RegisterContentTypeHandler(typeRegExp string, fn HandlerFunc) *Walker

RegisterContentTypeHandler registers a handler that will be called when a part's content type matches the given regular expression. If a part matches multiple handlers, the one registered first will be chosen.

func (*Walker) RegisterDefaultHandler

func (w *Walker) RegisterDefaultHandler(fn HandlerFunc) *Walker

RegisterDefaultHandler registers a handler that will be called on every part that doesn't match a registered content type/disposition handler.

func (*Walker) Walk

func (w *Walker) Walk() (err error)

type Writer

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

func (*Writer) Write

func (w *Writer) Write(ww io.Writer) error

Jump to

Keyboard shortcuts

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