Debian Codegraph @

lib/notmuch/threads.go

raw
1 //go:build notmuch
2 // +build notmuch
3
4 package notmuch
5
6 /*
7 #cgo LDFLAGS: -lnotmuch
8
9 #include <stdlib.h>
10 #include <notmuch.h>
11
12 */
13 import "C"
14
15 // Threads is an iterator over a set of threads.
16 type Threads struct {
17 thread *C.notmuch_thread_t
18 threads *C.notmuch_threads_t
19 }
20
21 // Next advances the Threads iterator to the next thread. Next returns false if
22 // no more threads are available
23 func (t *Threads) Next() bool {
24 if C.notmuch_threads_valid(t.threads) == 0 {
25 return false
26 }
27 t.thread = C.notmuch_threads_get(t.threads)
28 C.notmuch_threads_move_to_next(t.threads)
29 return true
30 }
31
32 // Thread returns the current thread in the iterator
33 func (t *Threads) Thread() Thread {
34 return Thread{
35 thread: t.thread,
36 }
37 }
38
39 // Close frees memory associated with a Threads iterator. This method is not
40 // strictly necessary to call, as the resources will be freed when the Query
41 // associated with the Threads object is freed.
42 func (t *Threads) Close() {
43 C.notmuch_threads_destroy(t.threads)
44 }