+
+
+class IndexOptions(base.NotmuchObject):
+ """Indexing options.
+
+ This represents the indexing options which can be used to index a
+ message. See :meth:`Database.default_indexopts` to create an
+ instance of this. It can be used e.g. when indexing a new message
+ using :meth:`Database.add`.
+ """
+ _opts_p = base.MemoryPointer()
+
+ def __init__(self, parent, opts_p):
+ self._parent = parent
+ self._opts_p = opts_p
+
+ @property
+ def alive(self):
+ if not self._parent.alive:
+ return False
+ try:
+ self._opts_p
+ except errors.ObjectDestroyedError:
+ return False
+ else:
+ return True
+
+ def _destroy(self):
+ if self.alive:
+ capi.lib.notmuch_indexopts_destroy(self._opts_p)
+ self._opts_p = None
+
+ @property
+ def decrypt_policy(self):
+ """The decryption policy.
+
+ This is an enum from the :class:`DecryptionPolicy`. See the
+ `index.decrypt` section in :man:`notmuch-config` for details
+ on the options. **Do not set this to
+ :attr:`DecryptionPolicy.TRUE`** without considering the
+ security of your index.
+
+ You can change this policy by assigning a new
+ :class:`DecryptionPolicy` to this property.
+
+ :raises ObjectDestoryedError: if used after destroyed.
+
+ :returns: A :class:`DecryptionPolicy` enum instance.
+ """
+ raw = capi.lib.notmuch_indexopts_get_decrypt_policy(self._opts_p)
+ return DecryptionPolicy(raw)
+
+ @decrypt_policy.setter
+ def decrypt_policy(self, val):
+ ret = capi.lib.notmuch_indexopts_set_decrypt_policy(
+ self._opts_p, val.value)
+ if ret != capi.lib.NOTMUCH_STATUS_SUCCESS:
+ raise errors.NotmuchError(ret, msg)