[][src]Type Definition melib::backends::notmuch::bindings::notmuch_query_search_messages

type notmuch_query_search_messages = unsafe extern "C" fn(query: *mut notmuch_query_t, out: *mut *mut notmuch_messages_t) -> notmuch_status_t;

Execute a query for messages, returning a notmuch_messages_t object which can be used to iterate over the results. The returned messages 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_messages_t *messages;
     notmuch_message_t *message;

     query = notmuch_query_create (database, query_string);

     for (messages = notmuch_query_search_messages (query);
          notmuch_messages_valid (messages);
          notmuch_messages_move_to_next (messages))
     {
         message = notmuch_messages_get (messages);
         ....
         notmuch_message_destroy (message);
     }

     notmuch_query_destroy (query);

Note: If you are finished with a message before its containing query, you can call notmuch_message_destroy to clean up some memory sooner (as in the above example). Otherwise, if your message objects are long-lived, then you don't need to call notmuch_message_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_messages_t object. (For consistency, we do provide a notmuch_messages_destroy function, but there's no good reason to call it if the query is about to be destroyed).

If a Xapian exception occurs this function will return NULL.

@since libnotmuch 5 (notmuch 0.25)