libnotmuch

package
v0.0.0-...-cc1fdb3 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2023 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckVersion

func CheckVersion() error

CheckVersion verifies that package libnotmuch is compiled against a notmuch.h of the proper version. Currently v5.6.0 is the minimum required version

Types

type Database

type Database struct {
	// The path to the notmuch database. If Path is the empty string, the
	// location will be found in the following order:
	//
	// 1. The value of the environment variable NOTMUCH_DATABASE
	// 2. From the config file specified by Config
	// 3. From the Profile specified by profile, given by
	//    $XDG_DATA_HOME/notmuch/$PROFILE
	Path string

	// The path to the notmuch configuration file to use.
	Config string

	// If FindConfig is true, libnotmuch will attempt to locate a suitable
	// configuration file in the following order:
	//
	// 1. The value of the environment variable NOTMUCH_CONFIG
	// 2. $XDG_CONFIG_HOME/notmuch/
	// 3. $HOME/.notmuch-config
	//
	// If not configuration file is found, a STATUS_NO_CONFIG error will be
	// returned
	FindConfig bool

	// The profile to use. If Profile is non-empty, the value will be
	// appended to the paths determined for Config and Path. If Profile is
	// the empty string, the profile will be determined in the following
	// order:
	//
	// 1. The value of the environment variable NOTMUCH_PROFILE
	// 2. "default" if Config and/or Path are a directory, "" if they are a
	//    filepath
	Profile string
	// contains filtered or unexported fields
}

func (*Database) BeginAtomic

func (db *Database) BeginAtomic() error

Indicate the beginning of an atomic operation

func (*Database) Close

func (db *Database) Close() error

Close commits changes and closes the database, freeing any resources associated with it

func (*Database) Compact

func (db *Database) Compact(backupPath string) error

func (*Database) Create

func (db *Database) Create() error

Create creates a notmuch database at the Path

func (*Database) Directory

func (db *Database) Directory(relativePath string) (Directory, error)

Returns a Directory object relative to the path of the Database

func (*Database) EndAtomic

func (db *Database) EndAtomic() error

Indicate the end of an atomic operation

func (*Database) FindMessageByFilename

func (db *Database) FindMessageByFilename(filename string) (Message, error)

FindMessageByFilename finds a message by filename

func (*Database) FindMessageByID

func (db *Database) FindMessageByID(id string) (Message, error)

FindMessageByID finds a message by the Message-ID header field value

func (*Database) IndexFile

func (db *Database) IndexFile(path string) (Message, error)

IndexFile indexes a file with path relative to the database path, or an absolute path which share a common ancestor as the database path

func (*Database) LastStatus

func (db *Database) LastStatus() string

LastStatus returns the last status string for the database

func (*Database) NeedsUpgrade

func (db *Database) NeedsUpgrade() bool

NeedsUpgrade reports if the database must be upgraded before a write operation can be safely performed

func (*Database) Open

func (db *Database) Open(mode Mode) error

Open opens the database with the given mode. Caller must call Close when done to commit changes and free resources

func (*Database) Query

func (db *Database) Query(query string) (Query, error)

Create a new Query

func (*Database) RemoveFile

func (db *Database) RemoveFile(path string) error

Remove a file from the database. If this is the last file associated with a message, the message will be removed from the database.

func (*Database) Reopen

func (db *Database) Reopen(mode Mode) error

Reopen an open notmuch database, usually with a different mode

func (*Database) ResolvedPath

func (db *Database) ResolvedPath() string

Return the resolved path to the notmuch database

func (*Database) Revision

func (db *Database) Revision() (string, uint64)

Returns the UUID and LastMod of the notmuch database

func (*Database) Tags

func (db *Database) Tags() []string

Tags returns a slice of all tags in the database

type Directory

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

func (*Directory) Close

func (dir *Directory) Close()

func (*Directory) Delete

func (dir *Directory) Delete() error

Delete deletes a directory document from the database and destroys the underlying object. Any child directories and files must have been deleted firs the caller

func (*Directory) Directories

func (dir *Directory) Directories() []string

func (*Directory) Filenames

func (dir *Directory) Filenames() []string

func (*Directory) ModifiedTime

func (dir *Directory) ModifiedTime() time.Time

func (*Directory) SetModifiedTime

func (dir *Directory) SetModifiedTime(t time.Time) error

type ExcludeMode

type ExcludeMode int

type Flag

type Flag int
const (
	MESSAGE_FLAG_MATCH Flag = iota
	MESSAGE_FLAG_EXCLUDED
	MESSAGE_FLAG_GHOST
)

type Message

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

func (*Message) AddProperty

func (m *Message) AddProperty(key string, value string) error

func (*Message) AddTag

func (m *Message) AddTag(tag string) error

func (*Message) Close

func (m *Message) Close()

Close frees resources associated with the message

func (*Message) CountProperties

func (m *Message) CountProperties(key string) (int, error)

func (*Message) Date

func (m *Message) Date() time.Time

func (*Message) Filename

func (m *Message) Filename() string

Filename returns a single filename associated with the message. If the message has multiple filenames, the return value will be arbitrarily chosen

func (*Message) Filenames

func (m *Message) Filenames() []string

func (*Message) Flag

func (m *Message) Flag(flag Flag) (bool, error)

func (*Message) Freeze

func (m *Message) Freeze() error

func (*Message) HasMaildirFlag

func (m *Message) HasMaildirFlag(flag rune) (bool, error)

func (*Message) Header

func (m *Message) Header(field string) string

func (*Message) ID

func (m *Message) ID() string

ID returns the message ID

func (*Message) Properties

func (m *Message) Properties(key string, exact bool) *Properties

func (*Message) Property

func (m *Message) Property(key string) (string, error)

func (*Message) RemoveAllProperties

func (m *Message) RemoveAllProperties(key string) error

func (*Message) RemoveAllPropertiesWithPrefix

func (m *Message) RemoveAllPropertiesWithPrefix(prefix string) error

func (*Message) RemoveAllTags

func (m *Message) RemoveAllTags() error

func (*Message) RemoveProperty

func (m *Message) RemoveProperty(key string, value string) error

func (*Message) RemoveTag

func (m *Message) RemoveTag(tag string) error

func (*Message) Replies

func (m *Message) Replies() Messages

func (*Message) SyncMaildirFlagsToTags

func (m *Message) SyncMaildirFlagsToTags() error

SyncMaildirFlagsToTags syncs the current maildir flags to the notmuch tags

func (*Message) SyncTagsToMaildirFlags

func (m *Message) SyncTagsToMaildirFlags() error

SyncTagsToMaildirFlags adds/removes the appropriate tags to the maildir filename

func (*Message) Tags

func (m *Message) Tags() []string

func (*Message) Thaw

func (m *Message) Thaw() error

func (*Message) ThreadID

func (m *Message) ThreadID() string

ThreadID returns the thread ID of the message

func (*Message) TotalFiles

func (m *Message) TotalFiles() int

type Messages

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

func (*Messages) Close

func (m *Messages) Close()

Close frees memory associated with a Messages iterator. This method is not strictly necessary to call, as the resources will be freed when the Query associated with the Messages object is freed.

func (*Messages) Message

func (m *Messages) Message() Message

Message returns the current message in the iterator

func (*Messages) Next

func (m *Messages) Next() bool

Next advances the Messages iterator to the next message. Next returns false if no more messages are available

func (*Messages) Tags

func (m *Messages) Tags() []string

Tags returns a slice of all tags in the message list. WARNING: After calling tags, the message list can no longer be iterated; a new list must be created to iterate after calling Tags

type Mode

type Mode int
const (
	MODE_READ_ONLY  Mode = C.NOTMUCH_DATABASE_MODE_READ_ONLY
	MODE_READ_WRITE Mode = C.NOTMUCH_DATABASE_MODE_READ_WRITE
)

type Properties

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

func (*Properties) Key

func (p *Properties) Key() string

Returns the key of the current iterator location

func (*Properties) Next

func (p *Properties) Next() bool

Next advances the Properties iterator to the next property. Next returns false if no more properties are available

func (*Properties) Value

func (p *Properties) Value() string

type Query

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

func (*Query) Close

func (q *Query) Close()

Close frees resources associated with a query. Closing a query release all resources associated with any underlying search (Threads, Messages, etc)

func (*Query) CountMessages

func (q *Query) CountMessages() (int, error)

CountMessages returns the number of messages matching the query

func (*Query) CountThreads

func (q *Query) CountThreads() (int, error)

CountThreads returns the number of threads matching the query

func (*Query) Database

func (q *Query) Database() Database

Returns the Database associated with the query. The Path, Config, and Profile values will not be set on the returned valued

func (*Query) Exclude

func (q *Query) Exclude(val ExcludeMode)

Exclude sets the exclusion mode.

func (*Query) ExcludeTag

func (q *Query) ExcludeTag(tag string) error

ExcludeTag adds a tag to exclude from the results

func (*Query) Messages

func (q *Query) Messages() (Messages, error)

Messages returns an iterator over the messages that match the query

func (*Query) Sort

func (q *Query) Sort(sort SortMode)

Sort sets the sort order of the results

func (*Query) SortMode

func (q *Query) SortMode() SortMode

SortMode returns the current sort order of the results

func (*Query) String

func (q *Query) String() string

Return the string of the query

func (*Query) Threads

func (q *Query) Threads() (Threads, error)

Threads returns an iterator over the threads that match the query

type SortMode

type SortMode int
const (
	SORT_OLDEST_FIRST SortMode = C.NOTMUCH_SORT_OLDEST_FIRST
	SORT_NEWEST_FIRST SortMode = C.NOTMUCH_SORT_NEWEST_FIRST
	SORT_MESSAGE_ID   SortMode = C.NOTMUCH_SORT_MESSAGE_ID
	SORT_UNSORTED     SortMode = C.NOTMUCH_SORT_UNSORTED
)

type Status

type Status int

Status codes used for the return values of most functions

const (
	STATUS_SUCCESS                        Status = C.NOTMUCH_STATUS_SUCCESS
	STATUS_OUT_OF_MEMORY                  Status = C.NOTMUCH_STATUS_OUT_OF_MEMORY
	STATUS_READ_ONLY_DATABASE             Status = C.NOTMUCH_STATUS_READ_ONLY_DATABASE
	STATUS_XAPIAN_EXCEPTION               Status = C.NOTMUCH_STATUS_XAPIAN_EXCEPTION
	STATUS_FILE_ERROR                     Status = C.NOTMUCH_STATUS_FILE_ERROR
	STATUS_FILE_NOT_EMAIL                 Status = C.NOTMUCH_STATUS_FILE_NOT_EMAIL
	STATUS_DUPLICATE_MESSAGE_ID           Status = C.NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID
	STATUS_NULL_POINTER                   Status = C.NOTMUCH_STATUS_NULL_POINTER
	STATUS_TAG_TOO_LONG                   Status = C.NOTMUCH_STATUS_TAG_TOO_LONG
	STATUS_UNBALANCED_FREEZE_THAW         Status = C.NOTMUCH_STATUS_UNBALANCED_FREEZE_THAW
	STATUS_UNBALANCED_ATOMIC              Status = C.NOTMUCH_STATUS_UNBALANCED_ATOMIC
	STATUS_UNSUPPORTED_OPERATION          Status = C.NOTMUCH_STATUS_UNSUPPORTED_OPERATION
	STATUS_UPGRADE_REQUIRED               Status = C.NOTMUCH_STATUS_UPGRADE_REQUIRED
	STATUS_PATH_ERROR                     Status = C.NOTMUCH_STATUS_PATH_ERROR
	STATUS_IGNORED                        Status = C.NOTMUCH_STATUS_IGNORED
	STATUS_ILLEGAL_ARGUMENT               Status = C.NOTMUCH_STATUS_ILLEGAL_ARGUMENT
	STATUS_MALFORMED_CRYPTO_PROTOCOL      Status = C.NOTMUCH_STATUS_MALFORMED_CRYPTO_PROTOCOL
	STATUS_FAILED_CRYPTO_CONTEXT_CREATION Status = C.NOTMUCH_STATUS_FAILED_CRYPTO_CONTEXT_CREATION
	STATUS_UNKNOWN_CRYPTO_PROTOCOL        Status = C.NOTMUCH_STATUS_UNKNOWN_CRYPTO_PROTOCOL
	STATUS_NO_CONFIG                      Status = C.NOTMUCH_STATUS_NO_CONFIG
	STATUS_NO_DATABASE                    Status = C.NOTMUCH_STATUS_NO_DATABASE
	STATUS_DATABASE_EXISTS                Status = C.NOTMUCH_STATUS_DATABASE_EXISTS
	STATUS_BAD_QUERY_SYNTAX               Status = C.NOTMUCH_STATUS_BAD_QUERY_SYNTAX
	STATUS_NO_MAIL_ROOT                   Status = C.NOTMUCH_STATUS_NO_MAIL_ROOT
	STATUS_CLOSED_DATABASE                Status = C.NOTMUCH_STATUS_CLOSED_DATABASE
)

func (Status) Error

func (s Status) Error() string

type Thread

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

func (*Thread) Authors

func (t *Thread) Authors() string

Returns a string of authors of the thread

func (*Thread) Close

func (t *Thread) Close()

func (*Thread) ID

func (t *Thread) ID() string

ID returns the thread ID

func (*Thread) Matches

func (t *Thread) Matches() int

Matches returns the number of messages in the thread that matched the query

func (*Thread) Messages

func (t *Thread) Messages() Messages

Messages returns an iterator over the messages in the thread. Messages are sorted oldest-first

func (*Thread) NewestDate

func (t *Thread) NewestDate() time.Time

Returns the sent-date of the newest message in the thread

func (*Thread) OldestDate

func (t *Thread) OldestDate() time.Time

Returns the sent-date of the oldest message in the thread

func (*Thread) Subject

func (t *Thread) Subject() string

Returns the subject of the thread

func (*Thread) Tags

func (t *Thread) Tags() []string

Tags returns a slice of all tags in the thread

func (*Thread) TopLevelMessages

func (t *Thread) TopLevelMessages() Messages

TopLevelMessages returns an iterator over the top level messages in the thread. Messages are sorted oldest-first

func (*Thread) TotalFiles

func (t *Thread) TotalFiles() int

TotalMessages returns the total number of files in the thread

func (*Thread) TotalMessages

func (t *Thread) TotalMessages() int

TotalMessages returns the total number of messages in the thread

type Threads

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

Threads is an iterator over a set of threads.

func (*Threads) Close

func (t *Threads) Close()

Close frees memory associated with a Threads iterator. This method is not strictly necessary to call, as the resources will be freed when the Query associated with the Threads object is freed.

func (*Threads) Next

func (t *Threads) Next() bool

Next advances the Threads iterator to the next thread. Next returns false if no more threads are available

func (*Threads) Thread

func (t *Threads) Thread() Thread

Thread returns the current thread in the iterator

Jump to

Keyboard shortcuts

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