package imapwire
import "github.com/emersion/go-imap/v2/internal/imapwire"
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
- func NewContinuationRequest() *ContinuationRequest
- func (cont *ContinuationRequest) Cancel(err error)
- func (cont *ContinuationRequest) Done(text string)
- func (cont *ContinuationRequest) Wait() (string, error)
- type Decoder
- func NewDecoder(r *bufio.Reader, side ConnSide) *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 NewEncoder(w *bufio.Writer, side ConnSide) *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
Functions ¶
func IsAtomChar ¶
IsAtomChar returns true if ch is an ATOM-CHAR.
func ParseSeqSet ¶
Types ¶
type ConnSide ¶
type ConnSide int
ConnSide describes the side of a connection: client or server.
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 // MaxSize defines a maximum number of bytes to be read from the input. // Literals are ignored. MaxSize int64 // 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) Atom ¶
func (*Decoder) CRLF ¶
func (*Decoder) DiscardLine ¶
func (dec *Decoder) DiscardLine()
func (*Decoder) DiscardUntilByte ¶
func (*Decoder) DiscardValue ¶
func (*Decoder) EOF ¶
EOF returns true if end-of-file is reached.
func (*Decoder) Err ¶
Err returns the decoder error, if any.
func (*Decoder) Expect ¶
Expect sets the decoder error if ok is false.
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) ExpectNIL ¶
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) ExpectSP ¶
func (*Decoder) ExpectSpecial ¶
func (*Decoder) ExpectString ¶
func (*Decoder) ExpectText ¶
func (*Decoder) ExpectUID ¶
func (*Decoder) ExpectUIDSet ¶
func (*Decoder) Func ¶
func (*Decoder) List ¶
func (*Decoder) Literal ¶
func (*Decoder) LiteralReader ¶
func (dec *Decoder) LiteralReader() (lit *LiteralReader, nonSync, ok bool)
func (*Decoder) ModSeq ¶
func (*Decoder) Number ¶
func (*Decoder) Number64 ¶
func (*Decoder) Quoted ¶
func (*Decoder) SP ¶
func (*Decoder) Special ¶
func (*Decoder) String ¶
func (*Decoder) Text ¶
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 raw UTF-8 in 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) Atom ¶
func (*Encoder) BeginList ¶
func (enc *Encoder) BeginList() *ListEncoder
func (*Encoder) CRLF ¶
CRLF writes a "\r\n" sequence and flushes the buffered writer.
func (*Encoder) Flag ¶
func (*Encoder) List ¶
List writes a parenthesized list.
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) Mailbox ¶
func (*Encoder) MailboxAttr ¶
func (*Encoder) ModSeq ¶
func (*Encoder) NIL ¶
func (*Encoder) NumSet ¶
func (*Encoder) Number ¶
func (*Encoder) Number64 ¶
func (*Encoder) Quoted ¶
func (*Encoder) SP ¶
func (*Encoder) Special ¶
func (*Encoder) String ¶
func (*Encoder) Text ¶
func (*Encoder) UID ¶
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) Read ¶
func (lit *LiteralReader) Read(b []byte) (int, error)
func (*LiteralReader) Size ¶
func (lit *LiteralReader) Size() int64
type NumKind ¶
type NumKind int
func NumSetKind ¶
func NumSetKind(numSet imap.NumSet) NumKind
Source Files ¶
decoder.go encoder.go imapwire.go num.go
- Version
- v2.0.0-beta.5 (latest)
- Published
- Feb 14, 2025
- Platform
- linux/amd64
- Imports
- 10 packages
- Last checked
- 2 days ago –
Tools for package owners.