Files
aerc-fork-mirror/lib/notmuch/threads.go
Tim Culverhouse 3a55b8e6fd notmuch: add notmuch bindings
aerc is using an unmaintained fork of a not-well-functioning notmuch
binding library. Add custom bindings directly into the aerc repo to make
them more maintainable and more customizable to our needs.

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2023-08-30 22:10:20 +02:00

45 lines
987 B
Go

//go:build notmuch
// +build notmuch
package notmuch
/*
#cgo LDFLAGS: -lnotmuch
#include <stdlib.h>
#include <notmuch.h>
*/
import "C"
// Threads is an iterator over a set of threads.
type Threads struct {
thread *C.notmuch_thread_t
threads *C.notmuch_threads_t
}
// Next advances the Threads iterator to the next thread. Next returns false if
// no more threads are available
func (t *Threads) Next() bool {
if C.notmuch_threads_valid(t.threads) == 0 {
return false
}
t.thread = C.notmuch_threads_get(t.threads)
C.notmuch_threads_move_to_next(t.threads)
return true
}
// Thread returns the current thread in the iterator
func (t *Threads) Thread() Thread {
return Thread{
thread: t.thread,
}
}
// 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 (t *Threads) Close() {
C.notmuch_threads_destroy(t.threads)
}