imapnum

package
v2.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Range

type Range struct {
	Start, Stop uint32
}

Range represents a single seq-number or seq-range value (RFC 3501 ABNF). Values may be static (e.g. "1", "2:4") or dynamic (e.g. "*", "1:*"). A seq-number is represented by setting Start = Stop. Zero is used to represent "*", which is safe because seq-number uses nz-number rule. The order of values is always Start <= Stop, except when representing "n:*", where Start = n and Stop = 0.

func (Range) Contains

func (s Range) Contains(q uint32) bool

Contains returns true if the seq-number q is contained in range value s. The dynamic value "*" contains only other "*" values, the dynamic range "n:*" contains "*" and all numbers >= n.

func (Range) Less

func (s Range) Less(q uint32) bool

Less returns true if s precedes and does not contain seq-number q.

func (Range) Merge

func (s Range) Merge(t Range) (union Range, ok bool)

Merge combines range values s and t into a single union if the two intersect or one is a superset of the other. The order of s and t does not matter. If the values cannot be merged, s is returned unmodified and ok is set to false.

func (Range) String

func (s Range) String() string

String returns range value s as a seq-number or seq-range string.

type Set

type Set []Range

Set is used to represent a set of message sequence numbers or UIDs (see sequence-set ABNF rule). The zero value is an empty set.

func ParseSet

func ParseSet(set string) (Set, error)

ParseSet returns a new Set after parsing the set string.

func (*Set) AddNum

func (s *Set) AddNum(q ...uint32)

AddNum inserts new numbers into the set. The value 0 represents "*".

func (*Set) AddRange

func (s *Set) AddRange(start, stop uint32)

AddRange inserts a new range into the set.

func (*Set) AddSet

func (s *Set) AddSet(t Set)

AddSet inserts all values from t into s.

func (Set) Contains

func (s Set) Contains(q uint32) bool

Contains returns true if the non-zero sequence number or UID q is contained in the set. The dynamic range "n:*" contains all q >= n. It is the caller's responsibility to handle the special case where q is the maximum UID in the mailbox and q < n (i.e. the set cannot match UIDs against "*:n" or "*" since it doesn't know what the maximum value is).

func (Set) Dynamic

func (s Set) Dynamic() bool

Dynamic returns true if the set contains "*" or "n:*" values.

func (Set) Nums

func (s Set) Nums() (nums []uint32, ok bool)

Nums returns a slice of all numbers contained in the set.

func (Set) String

func (s Set) String() string

String returns a sorted representation of all contained number values.

Jump to

Keyboard shortcuts

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