Documentation ¶
Overview ¶
Package imapwire implements the IMAP wire protocol.
The IMAP wire protocol is defined in RFC 9051 section 4.
Index ¶
- func IsAtomChar(ch byte) bool
- func ParseSeqSet(s string) (imap.SeqSet, error)
- type ConnSide
- type ContinuationRequest
- type Decoder
- func (dec *Decoder) Atom(ptr *string) bool
- func (dec *Decoder) CRLF() bool
- func (dec *Decoder) DiscardLine()
- func (dec *Decoder) DiscardUntilByte(untilCh byte)
- func (dec *Decoder) DiscardValue() bool
- func (dec *Decoder) EOF() bool
- func (dec *Decoder) Err() error
- func (dec *Decoder) Expect(ok bool, name string) bool
- func (dec *Decoder) ExpectAString(ptr *string) bool
- func (dec *Decoder) ExpectAtom(ptr *string) bool
- func (dec *Decoder) ExpectBodyFldOctets(ptr *uint32) bool
- func (dec *Decoder) ExpectCRLF() bool
- func (dec *Decoder) ExpectList(f func() error) error
- func (dec *Decoder) ExpectLiteralReader() (lit *LiteralReader, nonSync bool, err error)
- func (dec *Decoder) ExpectMailbox(ptr *string) bool
- func (dec *Decoder) ExpectModSeq(ptr *uint64) bool
- func (dec *Decoder) ExpectNIL() bool
- func (dec *Decoder) ExpectNList(f func() error) error
- func (dec *Decoder) ExpectNString(ptr *string) bool
- func (dec *Decoder) ExpectNStringReader() (lit *LiteralReader, nonSync, ok bool)
- func (dec *Decoder) ExpectNumSet(kind NumKind, ptr *imap.NumSet) bool
- func (dec *Decoder) ExpectNumber(ptr *uint32) bool
- func (dec *Decoder) ExpectNumber64(ptr *int64) bool
- func (dec *Decoder) ExpectSP() bool
- func (dec *Decoder) ExpectSpecial(b byte) bool
- func (dec *Decoder) ExpectString(ptr *string) bool
- func (dec *Decoder) ExpectText(ptr *string) bool
- func (dec *Decoder) ExpectUID(ptr *imap.UID) bool
- func (dec *Decoder) ExpectUIDSet(ptr *imap.UIDSet) bool
- func (dec *Decoder) Func(ptr *string, valid func(ch byte) bool) bool
- func (dec *Decoder) List(f func() error) (isList bool, err error)
- func (dec *Decoder) Literal(ptr *string) bool
- func (dec *Decoder) LiteralReader() (lit *LiteralReader, nonSync, ok bool)
- func (dec *Decoder) ModSeq(ptr *uint64) bool
- func (dec *Decoder) Number(ptr *uint32) bool
- func (dec *Decoder) Number64(ptr *int64) bool
- func (dec *Decoder) Quoted(ptr *string) bool
- func (dec *Decoder) SP() bool
- func (dec *Decoder) Special(b byte) bool
- func (dec *Decoder) String(ptr *string) bool
- func (dec *Decoder) Text(ptr *string) bool
- type DecoderExpectError
- type Encoder
- func (enc *Encoder) Atom(s string) *Encoder
- func (enc *Encoder) BeginList() *ListEncoder
- func (enc *Encoder) CRLF() error
- func (enc *Encoder) Flag(flag imap.Flag) *Encoder
- func (enc *Encoder) List(n int, f func(i int)) *Encoder
- func (enc *Encoder) Literal(size int64, sync *ContinuationRequest) io.WriteCloser
- func (enc *Encoder) Mailbox(name string) *Encoder
- func (enc *Encoder) MailboxAttr(attr imap.MailboxAttr) *Encoder
- func (enc *Encoder) ModSeq(v uint64) *Encoder
- func (enc *Encoder) NIL() *Encoder
- func (enc *Encoder) NumSet(numSet imap.NumSet) *Encoder
- func (enc *Encoder) Number(v uint32) *Encoder
- func (enc *Encoder) Number64(v int64) *Encoder
- func (enc *Encoder) Quoted(s string) *Encoder
- func (enc *Encoder) SP() *Encoder
- func (enc *Encoder) Special(ch byte) *Encoder
- func (enc *Encoder) String(s string) *Encoder
- func (enc *Encoder) Text(s string) *Encoder
- func (enc *Encoder) UID(uid imap.UID) *Encoder
- type ListEncoder
- type LiteralReader
- type NumKind
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseSeqSet ¶
Types ¶
type ContinuationRequest ¶
type ContinuationRequest struct {
// contains filtered or unexported fields
}
ContinuationRequest is a continuation request.
The sender must call either Done or Cancel. The receiver must call Wait.
func NewContinuationRequest ¶
func NewContinuationRequest() *ContinuationRequest
func (*ContinuationRequest) Cancel ¶
func (cont *ContinuationRequest) Cancel(err error)
func (*ContinuationRequest) Done ¶
func (cont *ContinuationRequest) Done(text string)
func (*ContinuationRequest) Wait ¶
func (cont *ContinuationRequest) Wait() (string, error)
type Decoder ¶
type Decoder struct { // CheckBufferedLiteralFunc is called when a literal is about to be decoded // and needs to be fully buffered in memory. CheckBufferedLiteralFunc func(size int64, nonSync bool) error // contains filtered or unexported fields }
A Decoder reads IMAP data.
There are multiple families of methods:
- Methods directly named after IMAP grammar elements attempt to decode said element, and return false if it's another element.
- "Expect" methods do the same, but set the decoder error (see Err) on failure.
func NewDecoder ¶
NewDecoder creates a new decoder.
func (*Decoder) DiscardLine ¶
func (dec *Decoder) DiscardLine()
func (*Decoder) DiscardUntilByte ¶
func (*Decoder) DiscardValue ¶
func (*Decoder) ExpectAString ¶
func (*Decoder) ExpectAtom ¶
func (*Decoder) ExpectBodyFldOctets ¶
func (*Decoder) ExpectCRLF ¶
func (*Decoder) ExpectList ¶
func (*Decoder) ExpectLiteralReader ¶
func (dec *Decoder) ExpectLiteralReader() (lit *LiteralReader, nonSync bool, err error)
func (*Decoder) ExpectMailbox ¶
func (*Decoder) ExpectModSeq ¶
func (*Decoder) ExpectNList ¶
func (*Decoder) ExpectNString ¶
func (*Decoder) ExpectNStringReader ¶
func (dec *Decoder) ExpectNStringReader() (lit *LiteralReader, nonSync, ok bool)
func (*Decoder) ExpectNumSet ¶
func (*Decoder) ExpectNumber ¶
func (*Decoder) ExpectNumber64 ¶
func (*Decoder) ExpectSpecial ¶
func (*Decoder) ExpectString ¶
func (*Decoder) ExpectText ¶
func (*Decoder) ExpectUIDSet ¶
func (*Decoder) LiteralReader ¶
func (dec *Decoder) LiteralReader() (lit *LiteralReader, nonSync, ok bool)
type DecoderExpectError ¶
type DecoderExpectError struct {
Message string
}
DecoderExpectError is an error due to the Decoder.Expect family of methods.
func (*DecoderExpectError) Error ¶
func (err *DecoderExpectError) Error() string
type Encoder ¶
type Encoder struct { // QuotedUTF8 allows non-ASCII strings to be encoded as quoted strings. // This requires IMAP4rev2 to be available, or UTF8=ACCEPT to be enabled. QuotedUTF8 bool // LiteralMinus enables non-synchronizing literals for short payloads. // This requires IMAP4rev2 or LITERAL-. This is only meaningful for // clients. LiteralMinus bool // LiteralPlus enables non-synchronizing literals for all payloads. This // requires LITERAL+. This is only meaningful for clients. LiteralPlus bool // NewContinuationRequest creates a new continuation request. This is only // meaningful for clients. NewContinuationRequest func() *ContinuationRequest // contains filtered or unexported fields }
An Encoder writes IMAP data.
Most methods don't return an error, instead they defer error handling until CRLF is called. These methods return the Encoder so that calls can be chained.
func NewEncoder ¶
NewEncoder creates a new encoder.
func (*Encoder) BeginList ¶
func (enc *Encoder) BeginList() *ListEncoder
func (*Encoder) Literal ¶
func (enc *Encoder) Literal(size int64, sync *ContinuationRequest) io.WriteCloser
Literal writes a literal.
The caller must write exactly size bytes to the returned writer.
If sync is non-nil, the literal is synchronizing: the encoder will wait for nil to be sent to the channel before writing the literal data. If an error is sent to the channel, the literal will be cancelled.
func (*Encoder) MailboxAttr ¶
type ListEncoder ¶
type ListEncoder struct {
// contains filtered or unexported fields
}
func (*ListEncoder) End ¶
func (le *ListEncoder) End()
func (*ListEncoder) Item ¶
func (le *ListEncoder) Item() *Encoder
type LiteralReader ¶
type LiteralReader struct {
// contains filtered or unexported fields
}
func (*LiteralReader) Size ¶
func (lit *LiteralReader) Size() int64