Function notmuch_sys::notmuch_query_search_threads_st [] [src]

pub unsafe extern "C" fn notmuch_query_search_threads_st(
    query: *mut notmuch_query_t,
    out: *mut *mut notmuch_threads_t
) -> notmuch_status_t

Execute a query for threads, returning a notmuch_threads_t object which can be used to iterate over the results. The returned threads object is owned by the query and as such, will only be valid until notmuch_query_destroy.

Typical usage might be:

notmuch_query_t *query;
notmuch_threads_t *threads;
notmuch_thread_t *thread;

query = notmuch_query_create (database, query_string);

for (threads = notmuch_query_search_threads (query);
     notmuch_threads_valid (threads);
     notmuch_threads_move_to_next (threads))
{
    thread = notmuch_threads_get (threads);
    ....
    notmuch_thread_destroy (thread);
}

notmuch_query_destroy (query);

Note: If you are finished with a thread before its containing query, you can call notmuch_thread_destroy to clean up some memory sooner (as in the above example). Otherwise, if your thread objects are long-lived, then you don't need to call notmuch_thread_destroy and all the memory will still be reclaimed when the query is destroyed.

Note that there's no explicit destructor needed for the notmuch_threads_t object. (For consistency, we do provide a notmuch_threads_destroy function, but there's no good reason to call it if the query is about to be destroyed).

@since libnotmuch 4.2 (notmuch 0.20)