Generated file

Copy as Markdown

Other Tools

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_net_ssl_tokens_cache_h
#define mozilla_net_ssl_tokens_cache_h
/* Generated with cbindgen:0.29.1 */
/* DO NOT MODIFY THIS MANUALLY! This file was generated using cbindgen. */
#include "nsString.h"
#include <cstdarg>
#include <cstdint>
#include <cstdlib>
#include <ostream>
#include <new>
/// Microseconds since the Unix epoch, matching the C++ `PRTime` type.
using PrTime = int64_t;
/// FFI-safe representation of one persisted token record.
/// Cert chain data is excluded — see `PersistedRecord` for rationale.
struct SslTokensPersistedRecordFfi {
uint64_t id;
nsCString key;
PrTime expiration_time;
const uint8_t *token;
uintptr_t token_len;
uint8_t ev_status;
uint16_t ct_status;
uint8_t overridable_error;
};
/// Callback type for [`ssl_tokens_cache_read`].
using SslTokensReadCallback = void(*)(void *ctx, const SslTokensPersistedRecordFfi *record);
extern "C" {
/// Appends a record to the in-memory shadow copy.
///
/// # Safety
///
/// All pointer fields in `record` must be valid for their associated length
/// fields for the duration of this call.
void ssl_tokens_cache_append(const SslTokensPersistedRecordFfi *record);
/// Filters to `valid_ids`, serializes, and writes to disk atomically.
///
/// # Safety
///
/// If `valid_id_count > 0`, `valid_ids` must point to `valid_id_count` valid
/// `u64` values.
void ssl_tokens_cache_write(const nsCString *path,
const uint64_t *valid_ids,
uintptr_t valid_id_count);
/// Reads the persisted file and calls `callback` for each valid record.
///
/// # Safety
///
/// `callback` must be a valid function pointer. `ctx` must remain valid for
/// the duration of this call. The `callback` is invoked with a pointer to a
/// stack-allocated FFI struct; the pointer is only valid inside the callback.
void ssl_tokens_cache_read(const nsCString *path,
PrTime now,
SslTokensReadCallback callback,
void *ctx);
/// Removes the record with the given `id` from the in-memory shadow.
///
/// Called when a token is consumed by `Get()` or evicted, to keep the shadow
/// in sync without waiting for the next write.
///
/// # Safety
///
/// This function is safe to call from any thread with no preconditions.
void ssl_tokens_cache_remove(uint64_t id);
/// Clears all in-memory state.
///
/// # Safety
///
/// This function is safe to call from any thread with no preconditions.
void ssl_tokens_cache_clear();
/// Retains only records whose id is in `valid_ids`, discarding the rest.
///
/// Called after `RemoveByOriginAttributesPattern` to keep the shadow in sync
/// with the C++ cache for all origin-attribute dimensions, not just partitionKey.
///
/// # Safety
///
/// `valid_ids` must point to `valid_id_count` valid `u64` values.
void ssl_tokens_cache_retain_only(const uint64_t *valid_ids, uintptr_t valid_id_count);
} // extern "C"
#endif // mozilla_net_ssl_tokens_cache_h