#ifndef MAIL_CACHE_H
#define MAIL_CACHE_H
#include "mail-index.h"
struct mail_cache;
struct mail_cache_view;
struct mail_cache_transaction_ctx;
struct mail_cache_compress_lock;
enum mail_cache_decision_type {
/* Not needed currently */
/* Needed only for new mails. Drop when compressing. */
/* Needed. */
/* This decision has been forced manually, don't change it. */
};
enum mail_cache_field_type {
};
struct mail_cache_field {
const char *name;
unsigned int idx;
unsigned int field_size;
/* If higher than the current last_used field, update it */
};
struct mail_cache *
/* Register fields. fields[].idx is updated to contain field index.
If field already exists and its caching decision is NO, the decision is
updated to the input field's decision. */
struct mail_cache_field *fields,
unsigned int fields_count);
/* Returns registered field index, or UINT_MAX if not found. */
unsigned int
/* Returns specified field */
const struct mail_cache_field *
/* Returns a list of all registered fields */
struct mail_cache_field *
unsigned int *count_r);
/* Returns TRUE if cache should be compressed. */
/* Compress cache file. Offsets are updated to given transaction. The cache
compression lock should be kept until the transaction is committed.
mail_cache_compress_unlock() needs to be called afterwards. The lock doesn't
prevent updates to the cache while it's held, it only prevents another cache
compression. */
struct mail_index_transaction *trans,
struct mail_cache_compress_lock **lock_r);
/* Returns TRUE if there is at least something in the cache. */
struct mail_cache_view *
bool update);
/* Copy caching decisions */
struct mail_cache *src,
struct mail_cache *dst);
/* Get index transaction specific cache transaction. */
struct mail_cache_transaction_ctx *
struct mail_index_transaction *t);
/* Add new field to given record. Updates are not allowed. Fixed size fields
must be exactly the expected size. */
/* Returns TRUE if field is wanted to be added and it doesn't already exist.
If current caching decisions say not to cache this field, FALSE is returned.
If seq is 0, the existence isn't checked. */
/* Like mail_cache_field_want_add(), but in caching decisions FALSE is
returned only if the decision is a forced no. */
/* Notify cache that the mail is now closed. Any records added with
mail_cache_add() are unlikely to be required again. This mainly tells
INDEX=MEMORY that it can free up the memory used by the mail. */
/* Returns 1 if field exists, 0 if not, -1 if error. */
unsigned int field_idx);
/* Returns TRUE if something is cached for the message, FALSE if not. */
/* Returns current caching decision for given field. */
/* Set data_r and size_r to point to wanted field in cache file.
Returns 1 if field was found, 0 if not, -1 if error. */
/* Return specified cached headers. Returns 1 if all fields were found,
0 if not, -1 if error. dest is updated only if all fields were found. */
unsigned int fields_count);
/* "Error in index cache file %s: ...". */
/* Delete the cache file. */
/* Returns human-readable reason for why a cached field is missing for
the specified mail. This is mainly for debugging purposes, so the exact
field doesn't matter here. */
const char *
#endif