/* automatically generated by rust-bindgen 0.71.1 */

pub const NWEP_VERSION_MAJOR: u32 = 0;
pub const NWEP_VERSION_MINOR: u32 = 1;
pub const NWEP_VERSION_PATCH: u32 = 0;
pub const NWEP_VERSION: &[u8; 6] = b"0.1.0\0";
pub const NWEP_PROTO_VER: &[u8; 6] = b"WEB/1\0";
pub const NWEP_ALPN: &[u8; 6] = b"WEB/1\0";
pub const NWEP_ALPN_LEN: u32 = 5;
pub const NWEP_DEFAULT_PORT: u32 = 4433;
pub const NWEP_MAX_HEADERS: u32 = 128;
pub const NWEP_DEFAULT_MAX_STREAMS: u32 = 100;
pub const NWEP_ED25519_PUBKEY_LEN: u32 = 32;
pub const NWEP_ED25519_PRIVKEY_LEN: u32 = 32;
pub const NWEP_ED25519_SIG_LEN: u32 = 64;
pub const NWEP_NODEID_LEN: u32 = 32;
pub const NWEP_CHALLENGE_LEN: u32 = 32;
pub const NWEP_REQUEST_ID_LEN: u32 = 16;
pub const NWEP_TRACE_ID_LEN: u32 = 16;
pub const NWEP_MSG_REQUEST: u32 = 0;
pub const NWEP_MSG_RESPONSE: u32 = 1;
pub const NWEP_MSG_STREAM: u32 = 2;
pub const NWEP_MSG_NOTIFY: u32 = 3;
pub const NWEP_METHOD_READ: &[u8; 5] = b"read\0";
pub const NWEP_METHOD_WRITE: &[u8; 6] = b"write\0";
pub const NWEP_METHOD_UPDATE: &[u8; 7] = b"update\0";
pub const NWEP_METHOD_DELETE: &[u8; 7] = b"delete\0";
pub const NWEP_METHOD_CONNECT: &[u8; 8] = b"connect\0";
pub const NWEP_METHOD_AUTHENTICATE: &[u8; 13] = b"authenticate\0";
pub const NWEP_METHOD_HEARTBEAT: &[u8; 10] = b"heartbeat\0";
pub const NWEP_STATUS_OK: &[u8; 3] = b"ok\0";
pub const NWEP_STATUS_CREATED: &[u8; 8] = b"created\0";
pub const NWEP_STATUS_ACCEPTED: &[u8; 9] = b"accepted\0";
pub const NWEP_STATUS_NO_CONTENT: &[u8; 11] = b"no_content\0";
pub const NWEP_STATUS_BAD_REQUEST: &[u8; 12] = b"bad_request\0";
pub const NWEP_STATUS_UNAUTHORIZED: &[u8; 13] = b"unauthorized\0";
pub const NWEP_STATUS_FORBIDDEN: &[u8; 10] = b"forbidden\0";
pub const NWEP_STATUS_NOT_FOUND: &[u8; 10] = b"not_found\0";
pub const NWEP_STATUS_CONFLICT: &[u8; 9] = b"conflict\0";
pub const NWEP_STATUS_RATE_LIMITED: &[u8; 13] = b"rate_limited\0";
pub const NWEP_STATUS_INTERNAL_ERROR: &[u8; 15] = b"internal_error\0";
pub const NWEP_STATUS_UNAVAILABLE: &[u8; 12] = b"unavailable\0";
pub const NWEP_ERR_CONFIG_FILE_NOT_FOUND: i32 = -101;
pub const NWEP_ERR_CONFIG_PARSE_ERROR: i32 = -102;
pub const NWEP_ERR_CONFIG_INVALID_VALUE: i32 = -103;
pub const NWEP_ERR_CONFIG_MISSING_REQUIRED: i32 = -104;
pub const NWEP_ERR_CONFIG_VALIDATION_FAILED: i32 = -105;
pub const NWEP_ERR_NETWORK_CONN_FAILED: i32 = -201;
pub const NWEP_ERR_NETWORK_CONN_CLOSED: i32 = -202;
pub const NWEP_ERR_NETWORK_TIMEOUT: i32 = -203;
pub const NWEP_ERR_NETWORK_ADDR_IN_USE: i32 = -204;
pub const NWEP_ERR_NETWORK_ADDR_INVALID: i32 = -205;
pub const NWEP_ERR_NETWORK_SOCKET: i32 = -206;
pub const NWEP_ERR_NETWORK_TLS: i32 = -207;
pub const NWEP_ERR_NETWORK_QUIC: i32 = -208;
pub const NWEP_ERR_NETWORK_NO_SERVERS: i32 = -209;
pub const NWEP_ERR_CRYPTO_KEY_GEN_FAILED: i32 = -301;
pub const NWEP_ERR_CRYPTO_SIGN_FAILED: i32 = -302;
pub const NWEP_ERR_CRYPTO_VERIFY_FAILED: i32 = -303;
pub const NWEP_ERR_CRYPTO_HASH_FAILED: i32 = -304;
pub const NWEP_ERR_CRYPTO_INVALID_KEY: i32 = -305;
pub const NWEP_ERR_CRYPTO_INVALID_SIG: i32 = -306;
pub const NWEP_ERR_CRYPTO_ENCRYPT_FAILED: i32 = -307;
pub const NWEP_ERR_CRYPTO_DECRYPT_FAILED: i32 = -308;
pub const NWEP_ERR_CRYPTO_KEY_LOAD_FAILED: i32 = -309;
pub const NWEP_ERR_CRYPTO_KEY_SAVE_FAILED: i32 = -310;
pub const NWEP_ERR_CRYPTO_CERT_ERROR: i32 = -311;
pub const NWEP_ERR_CRYPTO_PUBKEY_MISMATCH: i32 = -381;
pub const NWEP_ERR_CRYPTO_NODEID_MISMATCH: i32 = -382;
pub const NWEP_ERR_CRYPTO_CHALLENGE_FAILED: i32 = -383;
pub const NWEP_ERR_CRYPTO_SERVER_SIG_INVALID: i32 = -384;
pub const NWEP_ERR_CRYPTO_CLIENT_SIG_INVALID: i32 = -385;
pub const NWEP_ERR_CRYPTO_AUTH_TIMEOUT: i32 = -320;
pub const NWEP_ERR_PROTO_INVALID_MESSAGE: i32 = -401;
pub const NWEP_ERR_PROTO_INVALID_METHOD: i32 = -402;
pub const NWEP_ERR_PROTO_INVALID_HEADER: i32 = -403;
pub const NWEP_ERR_PROTO_MSG_TOO_LARGE: i32 = -404;
pub const NWEP_ERR_PROTO_STREAM_ERROR: i32 = -405;
pub const NWEP_ERR_PROTO_INVALID_STATUS: i32 = -406;
pub const NWEP_ERR_PROTO_CONNECT_REQUIRED: i32 = -407;
pub const NWEP_ERR_PROTO_TOO_MANY_HEADERS: i32 = -408;
pub const NWEP_ERR_PROTO_HEADER_TOO_LARGE: i32 = -409;
pub const NWEP_ERR_PROTO_0RTT_REJECTED: i32 = -410;
pub const NWEP_ERR_PROTO_MISSING_HEADER: i32 = -411;
pub const NWEP_ERR_PROTO_ROLE_MISMATCH: i32 = -412;
pub const NWEP_ERR_PROTO_UNAUTHORIZED: i32 = -413;
pub const NWEP_ERR_PROTO_PATH_NOT_FOUND: i32 = -414;
pub const NWEP_ERR_PROTO_VERSION_MISMATCH: i32 = -481;
pub const NWEP_ERR_IDENTITY_INVALID_NODEID: i32 = -501;
pub const NWEP_ERR_IDENTITY_INVALID_ADDR: i32 = -502;
pub const NWEP_ERR_IDENTITY_AUTH_FAILED: i32 = -503;
pub const NWEP_ERR_IDENTITY_CHALLENGE_EXPIRED: i32 = -504;
pub const NWEP_ERR_IDENTITY_NO_RECOVERY: i32 = -505;
pub const NWEP_ERR_IDENTITY_RECOVERY_MISMATCH: i32 = -506;
pub const NWEP_ERR_IDENTITY_INVALID_SHARE: i32 = -507;
pub const NWEP_ERR_IDENTITY_SHARE_COMBINE: i32 = -508;
pub const NWEP_ERR_IDENTITY_INVALID_THRESHOLD: i32 = -509;
pub const NWEP_ERR_IDENTITY_ROTATION_IN_PROGRESS: i32 = -510;
pub const NWEP_ERR_IDENTITY_KEY_MISMATCH: i32 = -581;
pub const NWEP_ERR_IDENTITY_REVOKED: i32 = -582;
pub const NWEP_ERR_STORAGE_FILE_NOT_FOUND: i32 = -601;
pub const NWEP_ERR_STORAGE_READ_ERROR: i32 = -602;
pub const NWEP_ERR_STORAGE_WRITE_ERROR: i32 = -603;
pub const NWEP_ERR_STORAGE_PERMISSION: i32 = -604;
pub const NWEP_ERR_STORAGE_DISK_FULL: i32 = -605;
pub const NWEP_ERR_STORAGE_KEY_NOT_FOUND: i32 = -606;
pub const NWEP_ERR_STORAGE_INDEX_OUT_OF_RANGE: i32 = -607;
pub const NWEP_ERR_STORAGE_CORRUPTED: i32 = -681;
pub const NWEP_ERR_TRUST_PARSE_ERROR: i32 = -701;
pub const NWEP_ERR_TRUST_INVALID_ENTRY: i32 = -702;
pub const NWEP_ERR_TRUST_INVALID_SIG: i32 = -703;
pub const NWEP_ERR_TRUST_QUORUM_NOT_REACHED: i32 = -704;
pub const NWEP_ERR_TRUST_INVALID_PROOF: i32 = -705;
pub const NWEP_ERR_TRUST_ENTRY_NOT_FOUND: i32 = -706;
pub const NWEP_ERR_TRUST_CHECKPOINT_STALE: i32 = -708;
pub const NWEP_ERR_TRUST_ANCHOR_UNKNOWN: i32 = -709;
pub const NWEP_ERR_TRUST_DUPLICATE_BINDING: i32 = -711;
pub const NWEP_ERR_TRUST_NODE_NOT_FOUND: i32 = -712;
pub const NWEP_ERR_TRUST_ALREADY_REVOKED: i32 = -713;
pub const NWEP_ERR_TRUST_INVALID_AUTH: i32 = -714;
pub const NWEP_ERR_TRUST_UNAUTHORIZED: i32 = -715;
pub const NWEP_ERR_TRUST_TYPE_NOT_ALLOWED: i32 = -716;
pub const NWEP_ERR_TRUST_KEY_MISMATCH: i32 = -717;
pub const NWEP_ERR_TRUST_STORAGE: i32 = -718;
pub const NWEP_ERR_TRUST_LOG_CORRUPTED: i32 = -781;
pub const NWEP_ERR_TRUST_EQUIVOCATION: i32 = -782;
pub const NWEP_ERR_INTERNAL_UNKNOWN: i32 = -801;
pub const NWEP_ERR_INTERNAL_NOT_IMPLEMENTED: i32 = -802;
pub const NWEP_ERR_INTERNAL_INVALID_STATE: i32 = -803;
pub const NWEP_ERR_INTERNAL_NULL_PTR: i32 = -804;
pub const NWEP_ERR_INTERNAL_NOMEM: i32 = -805;
pub const NWEP_ERR_INTERNAL_INVALID_ARG: i32 = -806;
pub const NWEP_ERR_INTERNAL_CALLBACK_FAILURE: i32 = -807;
pub const NWEP_ERR_INTERNAL_NOBUF: i32 = -808;
pub const NWEP_ERR_FATAL_THRESHOLD: u32 = 80;
pub const NWEP_ERR_CONTEXT_MAX: u32 = 8;
pub const NWEP_BASE58_ADDR_LEN: u32 = 66;
pub const NWEP_SHAMIR_MAX_SHARES: u32 = 255;
pub const NWEP_SHAMIR_MIN_THRESHOLD: u32 = 2;
pub const NWEP_KEY_OVERLAP_SECONDS: u32 = 300;
pub const NWEP_MAX_ACTIVE_KEYS: u32 = 2;
pub const NWEP_LOG_ENTRY_MAX_SIZE: u32 = 256;
pub const NWEP_MERKLE_PROOF_MAX_DEPTH: u32 = 64;
pub const NWEP_MERKLE_PROOF_MAX_SIZE: u32 = 2100;
pub const NWEP_URL_MAX_LEN: u32 = 512;
pub const NWEP_FRAME_HEADER_SIZE: u32 = 4;
pub const NWEP_MSG_TYPE_SIZE: u32 = 1;
pub const NWEP_HDR_METHOD: &[u8; 8] = b":method\0";
pub const NWEP_HDR_PATH: &[u8; 6] = b":path\0";
pub const NWEP_HDR_VERSION: &[u8; 9] = b":version\0";
pub const NWEP_HDR_STATUS: &[u8; 8] = b":status\0";
pub const NWEP_HDR_REQUEST_ID: &[u8; 11] = b"request-id\0";
pub const NWEP_HDR_CLIENT_ID: &[u8; 10] = b"client-id\0";
pub const NWEP_HDR_SERVER_ID: &[u8; 10] = b"server-id\0";
pub const NWEP_HDR_CHALLENGE: &[u8; 10] = b"challenge\0";
pub const NWEP_HDR_CHALLENGE_RESPONSE: &[u8; 19] = b"challenge-response\0";
pub const NWEP_HDR_SERVER_CHALLENGE: &[u8; 17] = b"server-challenge\0";
pub const NWEP_HDR_AUTH_RESPONSE: &[u8; 14] = b"auth-response\0";
pub const NWEP_HDR_MAX_STREAMS: &[u8; 12] = b"max-streams\0";
pub const NWEP_HDR_MAX_MESSAGE_SIZE: &[u8; 17] = b"max-message-size\0";
pub const NWEP_HDR_COMPRESSION: &[u8; 12] = b"compression\0";
pub const NWEP_HDR_ROLES: &[u8; 6] = b"roles\0";
pub const NWEP_HDR_TRANSCRIPT_SIG: &[u8; 21] = b"transcript-signature\0";
pub const NWEP_HDR_STATUS_DETAILS: &[u8; 15] = b"status-details\0";
pub const NWEP_HDR_RETRY_AFTER: &[u8; 12] = b"retry-after\0";
pub const NWEP_HDR_TRACE_ID: &[u8; 9] = b"trace-id\0";
pub const NWEP_HDR_EVENT: &[u8; 7] = b":event\0";
pub const NWEP_HDR_NOTIFY_ID: &[u8; 10] = b"notify-id\0";
pub const NWEP_NOTIFY_ID_LEN: u32 = 16;
pub const NWEP_BLS_PUBKEY_LEN: u32 = 48;
pub const NWEP_BLS_PRIVKEY_LEN: u32 = 32;
pub const NWEP_BLS_SIG_LEN: u32 = 96;
pub const NWEP_CHECKPOINT_DST: &[u8; 17] = b"WEB/1-CHECKPOINT\0";
pub const NWEP_DEFAULT_ANCHOR_THRESHOLD: u32 = 5;
pub const NWEP_MAX_ANCHORS: u32 = 32;
pub const NWEP_MAX_CHECKPOINTS: u32 = 168;
pub const NWEP_ROLE_STR_REGULAR: &[u8; 8] = b"regular\0";
pub const NWEP_ROLE_STR_LOG_SERVER: &[u8; 11] = b"log_server\0";
pub const NWEP_ROLE_STR_ANCHOR: &[u8; 7] = b"anchor\0";
pub const NWEP_CACHE_DEFAULT_CAPACITY: u32 = 10000;
pub const NWEP_POOL_MAX_SERVERS: u32 = 32;
pub const NWEP_POOL_HEALTH_CHECK_FAILURES: u32 = 3;
pub type sa_family_t = ::std::os::raw::c_ushort;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct sockaddr {
    pub sa_family: sa_family_t,
    pub sa_data: [::std::os::raw::c_char; 14usize],
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
#[cfg(all(target_pointer_width = "64", not(target_os = "windows")))]
const _: () = {
    ["Size of sockaddr"][::std::mem::size_of::<sockaddr>() - 16usize];
    ["Alignment of sockaddr"][::std::mem::align_of::<sockaddr>() - 2usize];
    ["Offset of field: sockaddr::sa_family"][::std::mem::offset_of!(sockaddr, sa_family) - 0usize];
    ["Offset of field: sockaddr::sa_data"][::std::mem::offset_of!(sockaddr, sa_data) - 2usize];
};
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct sockaddr_storage {
    pub ss_family: sa_family_t,
    pub __ss_padding: [::std::os::raw::c_char; 118usize],
    pub __ss_align: ::std::os::raw::c_ulong,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
#[cfg(all(target_pointer_width = "64", not(target_os = "windows")))]
const _: () = {
    ["Size of sockaddr_storage"][::std::mem::size_of::<sockaddr_storage>() - 128usize];
    ["Alignment of sockaddr_storage"][::std::mem::align_of::<sockaddr_storage>() - 8usize];
    ["Offset of field: sockaddr_storage::ss_family"]
        [::std::mem::offset_of!(sockaddr_storage, ss_family) - 0usize];
    ["Offset of field: sockaddr_storage::__ss_padding"]
        [::std::mem::offset_of!(sockaddr_storage, __ss_padding) - 2usize];
    ["Offset of field: sockaddr_storage::__ss_align"]
        [::std::mem::offset_of!(sockaddr_storage, __ss_align) - 120usize];
};
#[doc = " @typedef\n\n :type:`nwep_ssize` is signed counterpart of size_t."]
pub type nwep_ssize = isize;
#[doc = " @typedef\n\n :type:`nwep_tstamp` is a timestamp in nanoseconds."]
pub type nwep_tstamp = u64;
#[doc = " @typedef\n\n :type:`nwep_duration` is a duration in nanoseconds."]
pub type nwep_duration = u64;
pub const nwep_error_category_NWEP_ERR_CAT_NONE: nwep_error_category = 0;
pub const nwep_error_category_NWEP_ERR_CAT_CONFIG: nwep_error_category = 1;
pub const nwep_error_category_NWEP_ERR_CAT_NETWORK: nwep_error_category = 2;
pub const nwep_error_category_NWEP_ERR_CAT_CRYPTO: nwep_error_category = 3;
pub const nwep_error_category_NWEP_ERR_CAT_PROTOCOL: nwep_error_category = 4;
pub const nwep_error_category_NWEP_ERR_CAT_IDENTITY: nwep_error_category = 5;
pub const nwep_error_category_NWEP_ERR_CAT_STORAGE: nwep_error_category = 6;
pub const nwep_error_category_NWEP_ERR_CAT_TRUST: nwep_error_category = 7;
pub const nwep_error_category_NWEP_ERR_CAT_INTERNAL: nwep_error_category = 8;
#[doc = " @enum\n\n :type:`nwep_error_category` defines the error category values."]
pub type nwep_error_category = ::std::os::raw::c_uint;
#[doc = " @struct\n\n :type:`nwep_error` represents an error with context chain for debugging."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_error {
    #[doc = " :member:`code` is the error code."]
    pub code: ::std::os::raw::c_int,
    #[doc = " :member:`context` is an array of context strings (most recent first)."]
    pub context: [*const ::std::os::raw::c_char; 8usize],
    #[doc = " :member:`context_count` is the number of context entries."]
    pub context_count: usize,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
#[cfg(all(target_pointer_width = "64", not(target_os = "windows")))]
const _: () = {
    ["Size of nwep_error"][::std::mem::size_of::<nwep_error>() - 80usize];
    ["Alignment of nwep_error"][::std::mem::align_of::<nwep_error>() - 8usize];
    ["Offset of field: nwep_error::code"][::std::mem::offset_of!(nwep_error, code) - 0usize];
    ["Offset of field: nwep_error::context"][::std::mem::offset_of!(nwep_error, context) - 8usize];
    ["Offset of field: nwep_error::context_count"]
        [::std::mem::offset_of!(nwep_error, context_count) - 72usize];
};
#[doc = " @functypedef\n\n :type:`nwep_malloc` is a custom memory allocator to replace malloc(3)."]
pub type nwep_malloc = ::std::option::Option<
    unsafe extern "C" fn(
        size: usize,
        user_data: *mut ::std::os::raw::c_void,
    ) -> *mut ::std::os::raw::c_void,
>;
#[doc = " @functypedef\n\n :type:`nwep_free` is a custom memory allocator to replace free(3)."]
pub type nwep_free = ::std::option::Option<
    unsafe extern "C" fn(ptr: *mut ::std::os::raw::c_void, user_data: *mut ::std::os::raw::c_void),
>;
#[doc = " @functypedef\n\n :type:`nwep_calloc` is a custom memory allocator to replace calloc(3)."]
pub type nwep_calloc = ::std::option::Option<
    unsafe extern "C" fn(
        nmemb: usize,
        size: usize,
        user_data: *mut ::std::os::raw::c_void,
    ) -> *mut ::std::os::raw::c_void,
>;
#[doc = " @functypedef\n\n :type:`nwep_realloc` is a custom memory allocator to replace realloc(3)."]
pub type nwep_realloc = ::std::option::Option<
    unsafe extern "C" fn(
        ptr: *mut ::std::os::raw::c_void,
        size: usize,
        user_data: *mut ::std::os::raw::c_void,
    ) -> *mut ::std::os::raw::c_void,
>;
#[doc = " @struct\n\n :type:`nwep_mem` is a custom memory allocator."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_mem {
    #[doc = " :member:`user_data` is an arbitrary user supplied data passed to each\n allocator function."]
    pub user_data: *mut ::std::os::raw::c_void,
    #[doc = " :member:`malloc` is a custom allocator function to replace malloc(3)."]
    pub malloc: nwep_malloc,
    #[doc = " :member:`free` is a custom allocator function to replace free(3)."]
    pub free: nwep_free,
    #[doc = " :member:`calloc` is a custom allocator function to replace calloc(3)."]
    pub calloc: nwep_calloc,
    #[doc = " :member:`realloc` is a custom allocator function to replace realloc(3)."]
    pub realloc: nwep_realloc,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
#[cfg(all(target_pointer_width = "64", not(target_os = "windows")))]
const _: () = {
    ["Size of nwep_mem"][::std::mem::size_of::<nwep_mem>() - 40usize];
    ["Alignment of nwep_mem"][::std::mem::align_of::<nwep_mem>() - 8usize];
    ["Offset of field: nwep_mem::user_data"][::std::mem::offset_of!(nwep_mem, user_data) - 0usize];
    ["Offset of field: nwep_mem::malloc"][::std::mem::offset_of!(nwep_mem, malloc) - 8usize];
    ["Offset of field: nwep_mem::free"][::std::mem::offset_of!(nwep_mem, free) - 16usize];
    ["Offset of field: nwep_mem::calloc"][::std::mem::offset_of!(nwep_mem, calloc) - 24usize];
    ["Offset of field: nwep_mem::realloc"][::std::mem::offset_of!(nwep_mem, realloc) - 32usize];
};
#[doc = " @struct\n\n :type:`nwep_vec` is a buffer with a pointer and length."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_vec {
    #[doc = " :member:`base` points to the buffer."]
    pub base: *mut u8,
    #[doc = " :member:`len` is the length of the buffer."]
    pub len: usize,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
#[cfg(all(target_pointer_width = "64", not(target_os = "windows")))]
const _: () = {
    ["Size of nwep_vec"][::std::mem::size_of::<nwep_vec>() - 16usize];
    ["Alignment of nwep_vec"][::std::mem::align_of::<nwep_vec>() - 8usize];
    ["Offset of field: nwep_vec::base"][::std::mem::offset_of!(nwep_vec, base) - 0usize];
    ["Offset of field: nwep_vec::len"][::std::mem::offset_of!(nwep_vec, len) - 8usize];
};
#[doc = " @struct\n\n :type:`nwep_nodeid` is a 32-byte NodeID."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_nodeid {
    #[doc = " :member:`data` contains the NodeID bytes."]
    pub data: [u8; 32usize],
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
#[cfg(all(target_pointer_width = "64", not(target_os = "windows")))]
const _: () = {
    ["Size of nwep_nodeid"][::std::mem::size_of::<nwep_nodeid>() - 32usize];
    ["Alignment of nwep_nodeid"][::std::mem::align_of::<nwep_nodeid>() - 1usize];
    ["Offset of field: nwep_nodeid::data"][::std::mem::offset_of!(nwep_nodeid, data) - 0usize];
};
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_version` returns the version string of the nwep library."]
    pub fn nwep_version() -> *const ::std::os::raw::c_char;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_strerror` returns the error string for the given error code |liberr|."]
    pub fn nwep_strerror(liberr: ::std::os::raw::c_int) -> *const ::std::os::raw::c_char;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_err_is_fatal` returns nonzero if |liberr| is a fatal error that\n requires immediate connection termination. Fatal errors are those with\n codes ending in 81-99 within their category."]
    pub fn nwep_err_is_fatal(liberr: ::std::os::raw::c_int) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_err_category` returns the error category for the given error code.\n Returns :enum:`NWEP_ERR_CAT_NONE` for success (0) or unknown errors."]
    pub fn nwep_err_category(liberr: ::std::os::raw::c_int) -> nwep_error_category;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_err_category_str` returns the category name string for the given\n category."]
    pub fn nwep_err_category_str(cat: nwep_error_category) -> *const ::std::os::raw::c_char;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_err_to_status` returns the WEB/1 status token string appropriate\n for the given error code. This is used when generating error responses."]
    pub fn nwep_err_to_status(liberr: ::std::os::raw::c_int) -> *const ::std::os::raw::c_char;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_error_init` initializes an error struct with the given code."]
    pub fn nwep_error_init(err: *mut nwep_error, code: ::std::os::raw::c_int);
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_error_set_context` adds a context string to the error. Context\n strings are stored most-recent-first, up to :macro:`NWEP_ERR_CONTEXT_MAX`.\n Returns the error struct for chaining."]
    pub fn nwep_error_set_context(
        err: *mut nwep_error,
        context: *const ::std::os::raw::c_char,
    ) -> *mut nwep_error;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_error_format` formats the error with its context chain into a\n human-readable string. The format is:\n   [category:code] context1\n     caused by: context2\n     caused by: context3\n\n |buf| is the buffer to write to, |buflen| is the buffer size.\n Returns the number of bytes written (excluding null terminator), or\n the number of bytes that would have been written if the buffer was\n large enough."]
    pub fn nwep_error_format(
        err: *const nwep_error,
        buf: *mut ::std::os::raw::c_char,
        buflen: usize,
    ) -> usize;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_base58_encode` encodes |srclen| bytes from |src| into Base58.\n |dest| must have space for at least |destlen| bytes. The output is\n null-terminated.\n\n Returns the number of characters written (excluding null terminator),\n or 0 on error."]
    pub fn nwep_base58_encode(
        dest: *mut ::std::os::raw::c_char,
        destlen: usize,
        src: *const u8,
        srclen: usize,
    ) -> usize;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_base58_decode` decodes Base58 string |src| into |dest|.\n |dest| must have space for at least |destlen| bytes.\n\n Returns the number of bytes written, or 0 on error."]
    pub fn nwep_base58_decode(
        dest: *mut u8,
        destlen: usize,
        src: *const ::std::os::raw::c_char,
    ) -> usize;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_base58_encode_len` returns the buffer size needed to encode\n |srclen| bytes as Base58 (including null terminator)."]
    pub fn nwep_base58_encode_len(srclen: usize) -> usize;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_base58_decode_len` returns the maximum buffer size needed to\n decode a Base58 string of |srclen| characters."]
    pub fn nwep_base58_decode_len(srclen: usize) -> usize;
}
#[doc = " @struct\n\n :type:`nwep_keypair` holds an Ed25519 keypair. The private key is stored\n in a form suitable for signing operations."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_keypair {
    #[doc = " :member:`pubkey` is the 32-byte public key."]
    pub pubkey: [u8; 32usize],
    #[doc = " :member:`privkey` is the 64-byte expanded private key (seed + pubkey)."]
    pub privkey: [u8; 64usize],
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
#[cfg(all(target_pointer_width = "64", not(target_os = "windows")))]
const _: () = {
    ["Size of nwep_keypair"][::std::mem::size_of::<nwep_keypair>() - 96usize];
    ["Alignment of nwep_keypair"][::std::mem::align_of::<nwep_keypair>() - 1usize];
    ["Offset of field: nwep_keypair::pubkey"]
        [::std::mem::offset_of!(nwep_keypair, pubkey) - 0usize];
    ["Offset of field: nwep_keypair::privkey"]
        [::std::mem::offset_of!(nwep_keypair, privkey) - 32usize];
};
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_keypair_generate` generates a new Ed25519 keypair using the\n system's secure random number generator.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_keypair_generate(kp: *mut nwep_keypair) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_keypair_from_seed` derives an Ed25519 keypair from a 32-byte seed.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_keypair_from_seed(kp: *mut nwep_keypair, seed: *const u8) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_keypair_from_privkey` loads a keypair from a 64-byte private key\n (as returned by OpenSSL's Ed25519 routines or stored previously).\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_keypair_from_privkey(
        kp: *mut nwep_keypair,
        privkey: *const u8,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_keypair_clear` securely zeros the keypair memory."]
    pub fn nwep_keypair_clear(kp: *mut nwep_keypair);
}
#[doc = " @struct\n\n :type:`nwep_shamir_share` holds a single share of a split secret."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_shamir_share {
    pub index: u8,
    pub data: [u8; 32usize],
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
#[cfg(all(target_pointer_width = "64", not(target_os = "windows")))]
const _: () = {
    ["Size of nwep_shamir_share"][::std::mem::size_of::<nwep_shamir_share>() - 33usize];
    ["Alignment of nwep_shamir_share"][::std::mem::align_of::<nwep_shamir_share>() - 1usize];
    ["Offset of field: nwep_shamir_share::index"]
        [::std::mem::offset_of!(nwep_shamir_share, index) - 0usize];
    ["Offset of field: nwep_shamir_share::data"]
        [::std::mem::offset_of!(nwep_shamir_share, data) - 1usize];
};
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_shamir_split` splits a 32-byte secret into n shares with threshold t.\n Any t shares can reconstruct the original secret.\n\n |secret| is the 32-byte secret to split.\n |shares| is an array of at least n nwep_shamir_share structs.\n |n| is the total number of shares to create (2-255).\n |t| is the threshold (2-n).\n\n Returns 0 on success, or one of the following negative error codes:\n\n :macro:`NWEP_ERR_CRYPTO_INVALID_KEY`\n     Invalid parameters (n < t, t < 2, n > 255)."]
    pub fn nwep_shamir_split(
        secret: *const u8,
        shares: *mut nwep_shamir_share,
        n: usize,
        t: usize,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_shamir_combine` reconstructs a secret from t or more shares.\n\n |secret| receives the reconstructed 32-byte secret.\n |shares| is an array of at least t shares.\n |num_shares| is the number of shares provided (must be >= threshold used in split).\n\n Returns 0 on success, or one of the following negative error codes:\n\n :macro:`NWEP_ERR_CRYPTO_INVALID_KEY`\n     Invalid parameters or duplicate share indices."]
    pub fn nwep_shamir_combine(
        secret: *mut u8,
        shares: *const nwep_shamir_share,
        num_shares: usize,
    ) -> ::std::os::raw::c_int;
}
#[doc = " @struct\n\n :type:`nwep_recovery_authority` holds the recovery authority keypair\n which can revoke the primary identity key."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_recovery_authority {
    pub keypair: nwep_keypair,
    pub initialized: ::std::os::raw::c_int,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
#[cfg(all(target_pointer_width = "64", not(target_os = "windows")))]
const _: () = {
    ["Size of nwep_recovery_authority"]
        [::std::mem::size_of::<nwep_recovery_authority>() - 100usize];
    ["Alignment of nwep_recovery_authority"]
        [::std::mem::align_of::<nwep_recovery_authority>() - 4usize];
    ["Offset of field: nwep_recovery_authority::keypair"]
        [::std::mem::offset_of!(nwep_recovery_authority, keypair) - 0usize];
    ["Offset of field: nwep_recovery_authority::initialized"]
        [::std::mem::offset_of!(nwep_recovery_authority, initialized) - 96usize];
};
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_recovery_authority_new` generates a new recovery authority keypair.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_recovery_authority_new(ra: *mut nwep_recovery_authority) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_recovery_authority_from_keypair` initializes a recovery authority\n from an existing keypair.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_recovery_authority_from_keypair(
        ra: *mut nwep_recovery_authority,
        kp: *const nwep_keypair,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_recovery_authority_clear` securely zeros the recovery authority."]
    pub fn nwep_recovery_authority_clear(ra: *mut nwep_recovery_authority);
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_recovery_authority_get_pubkey` returns the public key of the\n recovery authority.\n\n Returns pointer to the 32-byte public key, or NULL if not initialized."]
    pub fn nwep_recovery_authority_get_pubkey(ra: *const nwep_recovery_authority) -> *const u8;
}
#[doc = " @struct\n\n :type:`nwep_timed_keypair` holds a keypair with rotation timestamps."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_timed_keypair {
    pub keypair: nwep_keypair,
    pub activated_at: nwep_tstamp,
    pub expires_at: nwep_tstamp,
    pub active: ::std::os::raw::c_int,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
#[cfg(all(target_pointer_width = "64", not(target_os = "windows")))]
const _: () = {
    ["Size of nwep_timed_keypair"][::std::mem::size_of::<nwep_timed_keypair>() - 120usize];
    ["Alignment of nwep_timed_keypair"][::std::mem::align_of::<nwep_timed_keypair>() - 8usize];
    ["Offset of field: nwep_timed_keypair::keypair"]
        [::std::mem::offset_of!(nwep_timed_keypair, keypair) - 0usize];
    ["Offset of field: nwep_timed_keypair::activated_at"]
        [::std::mem::offset_of!(nwep_timed_keypair, activated_at) - 96usize];
    ["Offset of field: nwep_timed_keypair::expires_at"]
        [::std::mem::offset_of!(nwep_timed_keypair, expires_at) - 104usize];
    ["Offset of field: nwep_timed_keypair::active"]
        [::std::mem::offset_of!(nwep_timed_keypair, active) - 112usize];
};
#[doc = " @struct\n\n :type:`nwep_revocation` holds a signed revocation record."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_revocation {
    pub nodeid: nwep_nodeid,
    pub timestamp: nwep_tstamp,
    pub recovery_pubkey: [u8; 32usize],
    pub signature: [u8; 64usize],
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
#[cfg(all(target_pointer_width = "64", not(target_os = "windows")))]
const _: () = {
    ["Size of nwep_revocation"][::std::mem::size_of::<nwep_revocation>() - 136usize];
    ["Alignment of nwep_revocation"][::std::mem::align_of::<nwep_revocation>() - 8usize];
    ["Offset of field: nwep_revocation::nodeid"]
        [::std::mem::offset_of!(nwep_revocation, nodeid) - 0usize];
    ["Offset of field: nwep_revocation::timestamp"]
        [::std::mem::offset_of!(nwep_revocation, timestamp) - 32usize];
    ["Offset of field: nwep_revocation::recovery_pubkey"]
        [::std::mem::offset_of!(nwep_revocation, recovery_pubkey) - 40usize];
    ["Offset of field: nwep_revocation::signature"]
        [::std::mem::offset_of!(nwep_revocation, signature) - 72usize];
};
#[doc = " @struct\n\n :type:`nwep_managed_identity` holds an identity with key rotation\n and recovery support."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_managed_identity {
    pub nodeid: nwep_nodeid,
    pub keys: [nwep_timed_keypair; 2usize],
    pub key_count: usize,
    pub recovery_pubkey: [u8; 32usize],
    pub has_recovery: ::std::os::raw::c_int,
    pub revoked: ::std::os::raw::c_int,
    pub revocation: nwep_revocation,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
#[cfg(all(target_pointer_width = "64", not(target_os = "windows")))]
const _: () = {
    ["Size of nwep_managed_identity"][::std::mem::size_of::<nwep_managed_identity>() - 456usize];
    ["Alignment of nwep_managed_identity"]
        [::std::mem::align_of::<nwep_managed_identity>() - 8usize];
    ["Offset of field: nwep_managed_identity::nodeid"]
        [::std::mem::offset_of!(nwep_managed_identity, nodeid) - 0usize];
    ["Offset of field: nwep_managed_identity::keys"]
        [::std::mem::offset_of!(nwep_managed_identity, keys) - 32usize];
    ["Offset of field: nwep_managed_identity::key_count"]
        [::std::mem::offset_of!(nwep_managed_identity, key_count) - 272usize];
    ["Offset of field: nwep_managed_identity::recovery_pubkey"]
        [::std::mem::offset_of!(nwep_managed_identity, recovery_pubkey) - 280usize];
    ["Offset of field: nwep_managed_identity::has_recovery"]
        [::std::mem::offset_of!(nwep_managed_identity, has_recovery) - 312usize];
    ["Offset of field: nwep_managed_identity::revoked"]
        [::std::mem::offset_of!(nwep_managed_identity, revoked) - 316usize];
    ["Offset of field: nwep_managed_identity::revocation"]
        [::std::mem::offset_of!(nwep_managed_identity, revocation) - 320usize];
};
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_managed_identity_new` creates a new managed identity with\n the given keypair and optional recovery authority.\n\n |identity| receives the initialized managed identity.\n |kp| is the initial keypair.\n |ra| is the recovery authority (may be NULL for no recovery support).\n |now| is the current timestamp.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_managed_identity_new(
        identity: *mut nwep_managed_identity,
        kp: *const nwep_keypair,
        ra: *const nwep_recovery_authority,
        now: nwep_tstamp,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_managed_identity_rotate` generates a new keypair and begins\n the rotation process. The old key remains active for the overlap period.\n\n |identity| is the managed identity.\n |now| is the current timestamp.\n\n Returns 0 on success, or one of the following negative error codes:\n\n :macro:`NWEP_ERR_IDENTITY_REVOKED`\n     Identity has been revoked.\n :macro:`NWEP_ERR_IDENTITY_ROTATION_IN_PROGRESS`\n     Maximum active keys reached (rotation in progress)."]
    pub fn nwep_managed_identity_rotate(
        identity: *mut nwep_managed_identity,
        now: nwep_tstamp,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_managed_identity_update` expires old keys based on current time.\n Should be called periodically.\n\n |identity| is the managed identity.\n |now| is the current timestamp."]
    pub fn nwep_managed_identity_update(identity: *mut nwep_managed_identity, now: nwep_tstamp);
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_managed_identity_get_active` returns the currently active keypair\n for signing. Returns the newest active key.\n\n Returns pointer to the active keypair, or NULL if revoked or no active key."]
    pub fn nwep_managed_identity_get_active(
        identity: *const nwep_managed_identity,
    ) -> *const nwep_keypair;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_managed_identity_get_active_keys` returns all currently active\n keypairs. Used for verification (accept signatures from any active key).\n\n |keys| receives pointers to active keypairs.\n |max_keys| is the size of the keys array.\n\n Returns the number of active keys written to the array."]
    pub fn nwep_managed_identity_get_active_keys(
        identity: *const nwep_managed_identity,
        keys: *mut *const nwep_keypair,
        max_keys: usize,
    ) -> usize;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_managed_identity_is_revoked` returns nonzero if the identity\n has been revoked."]
    pub fn nwep_managed_identity_is_revoked(
        identity: *const nwep_managed_identity,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_managed_identity_revoke` revokes the identity using the\n recovery authority. After revocation, no keys are active.\n\n |identity| is the managed identity to revoke.\n |ra| is the recovery authority (must match identity's recovery pubkey).\n |now| is the current timestamp.\n\n Returns 0 on success, or one of the following negative error codes:\n\n :macro:`NWEP_ERR_IDENTITY_NO_RECOVERY`\n     Identity has no recovery authority configured.\n :macro:`NWEP_ERR_IDENTITY_RECOVERY_MISMATCH`\n     Recovery authority does not match.\n :macro:`NWEP_ERR_IDENTITY_REVOKED`\n     Identity is already revoked."]
    pub fn nwep_managed_identity_revoke(
        identity: *mut nwep_managed_identity,
        ra: *const nwep_recovery_authority,
        now: nwep_tstamp,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_managed_identity_verify_revocation` verifies a revocation record.\n\n |revocation| is the revocation record to verify.\n\n Returns 0 if valid, or a negative error code."]
    pub fn nwep_managed_identity_verify_revocation(
        revocation: *const nwep_revocation,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_managed_identity_clear` securely zeros the managed identity."]
    pub fn nwep_managed_identity_clear(identity: *mut nwep_managed_identity);
}
pub const nwep_merkle_entry_type_NWEP_LOG_ENTRY_KEY_BINDING: nwep_merkle_entry_type = 1;
pub const nwep_merkle_entry_type_NWEP_LOG_ENTRY_KEY_ROTATION: nwep_merkle_entry_type = 2;
pub const nwep_merkle_entry_type_NWEP_LOG_ENTRY_REVOCATION: nwep_merkle_entry_type = 3;
pub const nwep_merkle_entry_type_NWEP_LOG_ENTRY_ANCHOR_CHANGE: nwep_merkle_entry_type = 4;
#[doc = " @enum\n\n :type:`nwep_merkle_entry_type` defines the types of log entries."]
pub type nwep_merkle_entry_type = ::std::os::raw::c_uint;
#[doc = " @struct\n\n :type:`nwep_merkle_entry` represents an entry in the Merkle log."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_merkle_entry {
    pub type_: nwep_merkle_entry_type,
    pub timestamp: nwep_tstamp,
    pub nodeid: nwep_nodeid,
    pub pubkey: [u8; 32usize],
    pub prev_pubkey: [u8; 32usize],
    pub recovery_pubkey: [u8; 32usize],
    pub signature: [u8; 64usize],
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
#[cfg(all(target_pointer_width = "64", not(target_os = "windows")))]
const _: () = {
    ["Size of nwep_merkle_entry"][::std::mem::size_of::<nwep_merkle_entry>() - 208usize];
    ["Alignment of nwep_merkle_entry"][::std::mem::align_of::<nwep_merkle_entry>() - 8usize];
    ["Offset of field: nwep_merkle_entry::type_"]
        [::std::mem::offset_of!(nwep_merkle_entry, type_) - 0usize];
    ["Offset of field: nwep_merkle_entry::timestamp"]
        [::std::mem::offset_of!(nwep_merkle_entry, timestamp) - 8usize];
    ["Offset of field: nwep_merkle_entry::nodeid"]
        [::std::mem::offset_of!(nwep_merkle_entry, nodeid) - 16usize];
    ["Offset of field: nwep_merkle_entry::pubkey"]
        [::std::mem::offset_of!(nwep_merkle_entry, pubkey) - 48usize];
    ["Offset of field: nwep_merkle_entry::prev_pubkey"]
        [::std::mem::offset_of!(nwep_merkle_entry, prev_pubkey) - 80usize];
    ["Offset of field: nwep_merkle_entry::recovery_pubkey"]
        [::std::mem::offset_of!(nwep_merkle_entry, recovery_pubkey) - 112usize];
    ["Offset of field: nwep_merkle_entry::signature"]
        [::std::mem::offset_of!(nwep_merkle_entry, signature) - 144usize];
};
#[doc = " @struct\n\n :type:`nwep_merkle_hash` holds a 32-byte Merkle tree hash."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_merkle_hash {
    pub data: [u8; 32usize],
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
#[cfg(all(target_pointer_width = "64", not(target_os = "windows")))]
const _: () = {
    ["Size of nwep_merkle_hash"][::std::mem::size_of::<nwep_merkle_hash>() - 32usize];
    ["Alignment of nwep_merkle_hash"][::std::mem::align_of::<nwep_merkle_hash>() - 1usize];
    ["Offset of field: nwep_merkle_hash::data"]
        [::std::mem::offset_of!(nwep_merkle_hash, data) - 0usize];
};
#[doc = " @struct\n\n :type:`nwep_merkle_proof` holds an inclusion proof for a log entry."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_merkle_proof {
    pub index: u64,
    pub log_size: u64,
    pub leaf_hash: nwep_merkle_hash,
    pub siblings: [nwep_merkle_hash; 64usize],
    pub depth: usize,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
#[cfg(all(target_pointer_width = "64", not(target_os = "windows")))]
const _: () = {
    ["Size of nwep_merkle_proof"][::std::mem::size_of::<nwep_merkle_proof>() - 2104usize];
    ["Alignment of nwep_merkle_proof"][::std::mem::align_of::<nwep_merkle_proof>() - 8usize];
    ["Offset of field: nwep_merkle_proof::index"]
        [::std::mem::offset_of!(nwep_merkle_proof, index) - 0usize];
    ["Offset of field: nwep_merkle_proof::log_size"]
        [::std::mem::offset_of!(nwep_merkle_proof, log_size) - 8usize];
    ["Offset of field: nwep_merkle_proof::leaf_hash"]
        [::std::mem::offset_of!(nwep_merkle_proof, leaf_hash) - 16usize];
    ["Offset of field: nwep_merkle_proof::siblings"]
        [::std::mem::offset_of!(nwep_merkle_proof, siblings) - 48usize];
    ["Offset of field: nwep_merkle_proof::depth"]
        [::std::mem::offset_of!(nwep_merkle_proof, depth) - 2096usize];
};
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_merkle_entry_encode` serializes a Merkle log entry.\n\n |buf| receives the serialized data.\n |buflen| is the buffer size.\n |entry| is the entry to serialize.\n\n Returns the number of bytes written, or a negative error code."]
    pub fn nwep_merkle_entry_encode(
        buf: *mut u8,
        buflen: usize,
        entry: *const nwep_merkle_entry,
    ) -> nwep_ssize;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_merkle_entry_decode` deserializes a Merkle log entry.\n\n |entry| receives the deserialized entry.\n |data| is the serialized data.\n |datalen| is the data length.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_merkle_entry_decode(
        entry: *mut nwep_merkle_entry,
        data: *const u8,
        datalen: usize,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_merkle_leaf_hash` computes the leaf hash for a Merkle log entry.\n Hash = SHA-256(0x00 || entry_bytes)\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_merkle_leaf_hash(
        hash: *mut nwep_merkle_hash,
        entry: *const nwep_merkle_entry,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_merkle_node_hash` computes an internal node hash.\n Hash = SHA-256(0x01 || left || right)\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_merkle_node_hash(
        hash: *mut nwep_merkle_hash,
        left: *const nwep_merkle_hash,
        right: *const nwep_merkle_hash,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_merkle_proof_verify` verifies an inclusion proof against a root hash.\n\n |proof| is the inclusion proof.\n |root| is the expected root hash.\n\n Returns 0 if valid, or a negative error code."]
    pub fn nwep_merkle_proof_verify(
        proof: *const nwep_merkle_proof,
        root: *const nwep_merkle_hash,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_merkle_proof_encode` serializes an inclusion proof.\n\n |buf| receives the serialized data.\n |buflen| is the buffer size.\n |proof| is the proof to serialize.\n\n Returns the number of bytes written, or a negative error code."]
    pub fn nwep_merkle_proof_encode(
        buf: *mut u8,
        buflen: usize,
        proof: *const nwep_merkle_proof,
    ) -> nwep_ssize;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_merkle_proof_decode` deserializes an inclusion proof.\n\n |proof| receives the deserialized proof.\n |data| is the serialized data.\n |datalen| is the data length.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_merkle_proof_decode(
        proof: *mut nwep_merkle_proof,
        data: *const u8,
        datalen: usize,
    ) -> ::std::os::raw::c_int;
}
#[doc = " @callback\n\n `nwep_log_append_cb` appends an entry to storage.\n Returns 0 on success, or negative error code."]
pub type nwep_log_append_cb = ::std::option::Option<
    unsafe extern "C" fn(
        user_data: *mut ::std::os::raw::c_void,
        index: u64,
        entry: *const u8,
        entry_len: usize,
    ) -> ::std::os::raw::c_int,
>;
#[doc = " @callback\n\n `nwep_log_get_cb` retrieves an entry from storage.\n Returns entry length on success, or negative error code."]
pub type nwep_log_get_cb = ::std::option::Option<
    unsafe extern "C" fn(
        user_data: *mut ::std::os::raw::c_void,
        index: u64,
        buf: *mut u8,
        buflen: usize,
    ) -> nwep_ssize,
>;
#[doc = " @callback\n\n `nwep_log_size_cb` returns the current log size (number of entries)."]
pub type nwep_log_size_cb =
    ::std::option::Option<unsafe extern "C" fn(user_data: *mut ::std::os::raw::c_void) -> u64>;
#[doc = " @struct\n\n :type:`nwep_log_storage` holds storage callbacks for the Merkle log."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_log_storage {
    pub append: nwep_log_append_cb,
    pub get: nwep_log_get_cb,
    pub size: nwep_log_size_cb,
    pub user_data: *mut ::std::os::raw::c_void,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
#[cfg(all(target_pointer_width = "64", not(target_os = "windows")))]
const _: () = {
    ["Size of nwep_log_storage"][::std::mem::size_of::<nwep_log_storage>() - 32usize];
    ["Alignment of nwep_log_storage"][::std::mem::align_of::<nwep_log_storage>() - 8usize];
    ["Offset of field: nwep_log_storage::append"]
        [::std::mem::offset_of!(nwep_log_storage, append) - 0usize];
    ["Offset of field: nwep_log_storage::get"]
        [::std::mem::offset_of!(nwep_log_storage, get) - 8usize];
    ["Offset of field: nwep_log_storage::size"]
        [::std::mem::offset_of!(nwep_log_storage, size) - 16usize];
    ["Offset of field: nwep_log_storage::user_data"]
        [::std::mem::offset_of!(nwep_log_storage, user_data) - 24usize];
};
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_merkle_log {
    _unused: [u8; 0],
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_merkle_log_new` creates a new Merkle log.\n\n |plog| receives the created log.\n |storage| provides the storage callbacks.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_merkle_log_new(
        plog: *mut *mut nwep_merkle_log,
        storage: *const nwep_log_storage,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_merkle_log_free` frees a Merkle log."]
    pub fn nwep_merkle_log_free(log: *mut nwep_merkle_log);
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_merkle_log_append` appends an entry to the log.\n\n |log| is the Merkle log.\n |entry| is the entry to append.\n |pindex| receives the index of the appended entry (may be NULL).\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_merkle_log_append(
        log: *mut nwep_merkle_log,
        entry: *const nwep_merkle_entry,
        pindex: *mut u64,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_merkle_log_get` retrieves an entry from the log.\n\n |log| is the Merkle log.\n |index| is the entry index.\n |entry| receives the entry.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_merkle_log_get(
        log: *mut nwep_merkle_log,
        index: u64,
        entry: *mut nwep_merkle_entry,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_merkle_log_size` returns the number of entries in the log."]
    pub fn nwep_merkle_log_size(log: *const nwep_merkle_log) -> u64;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_merkle_log_root` computes the current root hash.\n\n |log| is the Merkle log.\n |root| receives the root hash.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_merkle_log_root(
        log: *mut nwep_merkle_log,
        root: *mut nwep_merkle_hash,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_merkle_log_prove` generates an inclusion proof for an entry.\n\n |log| is the Merkle log.\n |index| is the entry index.\n |proof| receives the inclusion proof.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_merkle_log_prove(
        log: *mut nwep_merkle_log,
        index: u64,
        proof: *mut nwep_merkle_proof,
    ) -> ::std::os::raw::c_int;
}
#[doc = " @struct\n\n :type:`nwep_log_index_entry` holds the current state for a NodeID."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_log_index_entry {
    pub nodeid: nwep_nodeid,
    pub pubkey: [u8; 32usize],
    pub log_index: u64,
    pub revoked: ::std::os::raw::c_int,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
#[cfg(all(target_pointer_width = "64", not(target_os = "windows")))]
const _: () = {
    ["Size of nwep_log_index_entry"][::std::mem::size_of::<nwep_log_index_entry>() - 80usize];
    ["Alignment of nwep_log_index_entry"][::std::mem::align_of::<nwep_log_index_entry>() - 8usize];
    ["Offset of field: nwep_log_index_entry::nodeid"]
        [::std::mem::offset_of!(nwep_log_index_entry, nodeid) - 0usize];
    ["Offset of field: nwep_log_index_entry::pubkey"]
        [::std::mem::offset_of!(nwep_log_index_entry, pubkey) - 32usize];
    ["Offset of field: nwep_log_index_entry::log_index"]
        [::std::mem::offset_of!(nwep_log_index_entry, log_index) - 64usize];
    ["Offset of field: nwep_log_index_entry::revoked"]
        [::std::mem::offset_of!(nwep_log_index_entry, revoked) - 72usize];
};
#[doc = " @callback\n\n `nwep_index_get_cb` retrieves an index entry by NodeID.\n Returns 0 on success, NWEP_ERR_STORAGE_KEY_NOT_FOUND if not found."]
pub type nwep_index_get_cb = ::std::option::Option<
    unsafe extern "C" fn(
        user_data: *mut ::std::os::raw::c_void,
        nodeid: *const nwep_nodeid,
        entry: *mut nwep_log_index_entry,
    ) -> ::std::os::raw::c_int,
>;
#[doc = " @callback\n\n `nwep_index_put_cb` stores an index entry.\n Returns 0 on success, or negative error code."]
pub type nwep_index_put_cb = ::std::option::Option<
    unsafe extern "C" fn(
        user_data: *mut ::std::os::raw::c_void,
        entry: *const nwep_log_index_entry,
    ) -> ::std::os::raw::c_int,
>;
#[doc = " @struct\n\n :type:`nwep_log_index_storage` holds storage callbacks for the log index."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_log_index_storage {
    pub get: nwep_index_get_cb,
    pub put: nwep_index_put_cb,
    pub user_data: *mut ::std::os::raw::c_void,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
#[cfg(all(target_pointer_width = "64", not(target_os = "windows")))]
const _: () = {
    ["Size of nwep_log_index_storage"][::std::mem::size_of::<nwep_log_index_storage>() - 24usize];
    ["Alignment of nwep_log_index_storage"]
        [::std::mem::align_of::<nwep_log_index_storage>() - 8usize];
    ["Offset of field: nwep_log_index_storage::get"]
        [::std::mem::offset_of!(nwep_log_index_storage, get) - 0usize];
    ["Offset of field: nwep_log_index_storage::put"]
        [::std::mem::offset_of!(nwep_log_index_storage, put) - 8usize];
    ["Offset of field: nwep_log_index_storage::user_data"]
        [::std::mem::offset_of!(nwep_log_index_storage, user_data) - 16usize];
};
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_log_index {
    _unused: [u8; 0],
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_log_index_new` creates a new log index.\n\n |pindex| receives the created index.\n |storage| provides the storage callbacks.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_log_index_new(
        pindex: *mut *mut nwep_log_index,
        storage: *const nwep_log_index_storage,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_log_index_free` frees a log index."]
    pub fn nwep_log_index_free(index: *mut nwep_log_index);
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_log_index_lookup` looks up the current state for a NodeID.\n\n |index| is the log index.\n |nodeid| is the NodeID to look up.\n |entry| receives the index entry.\n\n Returns 0 on success, or one of the following negative error codes:\n\n :macro:`NWEP_ERR_STORAGE_KEY_NOT_FOUND`\n     NodeID not found in index."]
    pub fn nwep_log_index_lookup(
        index: *mut nwep_log_index,
        nodeid: *const nwep_nodeid,
        entry: *mut nwep_log_index_entry,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_log_index_update` updates the index from a Merkle log entry.\n\n |index| is the log index.\n |entry| is the Merkle log entry.\n |log_idx| is the entry's index in the log.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_log_index_update(
        index: *mut nwep_log_index,
        entry: *const nwep_merkle_entry,
        log_idx: u64,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_nodeid_from_pubkey` computes a NodeID from a public key.\n NodeID = SHA-256(pubkey || \"WEB/1\")\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_nodeid_from_pubkey(
        nodeid: *mut nwep_nodeid,
        pubkey: *const u8,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_nodeid_from_keypair` computes a NodeID from a keypair.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_nodeid_from_keypair(
        nodeid: *mut nwep_nodeid,
        kp: *const nwep_keypair,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_nodeid_eq` returns nonzero if two NodeIDs are equal."]
    pub fn nwep_nodeid_eq(a: *const nwep_nodeid, b: *const nwep_nodeid) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_nodeid_is_zero` returns nonzero if the NodeID is all zeros."]
    pub fn nwep_nodeid_is_zero(nodeid: *const nwep_nodeid) -> ::std::os::raw::c_int;
}
#[doc = " @struct\n\n :type:`nwep_addr` holds an IP address (IPv6 or IPv4-mapped) and NodeID."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_addr {
    #[doc = " :member:`ip` is the IPv6 address (IPv4 mapped as ::ffff:x.x.x.x)."]
    pub ip: [u8; 16usize],
    #[doc = " :member:`nodeid` is the NodeID."]
    pub nodeid: nwep_nodeid,
    #[doc = " :member:`port` is the port number (default 4433)."]
    pub port: u16,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
#[cfg(all(target_pointer_width = "64", not(target_os = "windows")))]
const _: () = {
    ["Size of nwep_addr"][::std::mem::size_of::<nwep_addr>() - 50usize];
    ["Alignment of nwep_addr"][::std::mem::align_of::<nwep_addr>() - 2usize];
    ["Offset of field: nwep_addr::ip"][::std::mem::offset_of!(nwep_addr, ip) - 0usize];
    ["Offset of field: nwep_addr::nodeid"][::std::mem::offset_of!(nwep_addr, nodeid) - 16usize];
    ["Offset of field: nwep_addr::port"][::std::mem::offset_of!(nwep_addr, port) - 48usize];
};
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_addr_encode` encodes an address to Base58.\n |dest| must have space for at least NWEP_BASE58_ADDR_LEN + 1 bytes.\n\n Returns the number of characters written (excluding null), or 0 on error."]
    pub fn nwep_addr_encode(
        dest: *mut ::std::os::raw::c_char,
        destlen: usize,
        addr: *const nwep_addr,
    ) -> usize;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_addr_decode` decodes a Base58 address string into an nwep_addr.\n This only decodes the address portion, not the full URL.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_addr_decode(
        addr: *mut nwep_addr,
        encoded: *const ::std::os::raw::c_char,
    ) -> ::std::os::raw::c_int;
}
#[doc = " @struct\n\n :type:`nwep_url` represents a parsed web:// URL."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_url {
    #[doc = " :member:`addr` is the decoded address."]
    pub addr: nwep_addr,
    #[doc = " :member:`path` is the path portion (null-terminated, max 256 chars)."]
    pub path: [::std::os::raw::c_char; 256usize],
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
#[cfg(all(target_pointer_width = "64", not(target_os = "windows")))]
const _: () = {
    ["Size of nwep_url"][::std::mem::size_of::<nwep_url>() - 306usize];
    ["Alignment of nwep_url"][::std::mem::align_of::<nwep_url>() - 2usize];
    ["Offset of field: nwep_url::addr"][::std::mem::offset_of!(nwep_url, addr) - 0usize];
    ["Offset of field: nwep_url::path"][::std::mem::offset_of!(nwep_url, path) - 50usize];
};
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_url_parse` parses a web:// URL string.\n Format: web://[address]:port/path\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_url_parse(
        url: *mut nwep_url,
        str_: *const ::std::os::raw::c_char,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_url_format` formats a URL into a string buffer.\n |dest| must have space for at least NWEP_URL_MAX_LEN bytes.\n\n Returns the number of characters written (excluding null), or 0 on error."]
    pub fn nwep_url_format(
        dest: *mut ::std::os::raw::c_char,
        destlen: usize,
        url: *const nwep_url,
    ) -> usize;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_addr_set_ipv4` sets an address to an IPv4-mapped IPv6 address."]
    pub fn nwep_addr_set_ipv4(addr: *mut nwep_addr, ipv4: u32);
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_addr_set_ipv6` sets an address to an IPv6 address."]
    pub fn nwep_addr_set_ipv6(addr: *mut nwep_addr, ipv6: *const u8);
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_sign` signs |msg| of |msglen| bytes using |kp|.\n |sig| must have space for 64 bytes.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_sign(
        sig: *mut u8,
        msg: *const u8,
        msglen: usize,
        kp: *const nwep_keypair,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_verify` verifies a signature |sig| on |msglen| bytes of |msg|\n using the public key |pubkey|.\n\n Returns 0 if the signature is valid, or a negative error code."]
    pub fn nwep_verify(
        sig: *const u8,
        msg: *const u8,
        msglen: usize,
        pubkey: *const u8,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_challenge_generate` generates a 32-byte random challenge nonce.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_challenge_generate(challenge: *mut u8) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_challenge_sign` signs a challenge using the keypair.\n |response| must have space for 64 bytes.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_challenge_sign(
        response: *mut u8,
        challenge: *const u8,
        kp: *const nwep_keypair,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_challenge_verify` verifies a challenge response signature.\n\n Returns 0 if valid, or a negative error code."]
    pub fn nwep_challenge_verify(
        response: *const u8,
        challenge: *const u8,
        pubkey: *const u8,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_random_bytes` fills |dest| with |len| cryptographically secure\n random bytes.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_random_bytes(dest: *mut u8, len: usize) -> ::std::os::raw::c_int;
}
#[doc = " @struct\n\n :type:`nwep_header` represents a single header name-value pair."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_header {
    #[doc = " :member:`name` is the header name (not null-terminated in wire format)."]
    pub name: *const u8,
    #[doc = " :member:`name_len` is the length of the header name."]
    pub name_len: usize,
    #[doc = " :member:`value` is the header value (not null-terminated in wire format)."]
    pub value: *const u8,
    #[doc = " :member:`value_len` is the length of the header value."]
    pub value_len: usize,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
#[cfg(all(target_pointer_width = "64", not(target_os = "windows")))]
const _: () = {
    ["Size of nwep_header"][::std::mem::size_of::<nwep_header>() - 32usize];
    ["Alignment of nwep_header"][::std::mem::align_of::<nwep_header>() - 8usize];
    ["Offset of field: nwep_header::name"][::std::mem::offset_of!(nwep_header, name) - 0usize];
    ["Offset of field: nwep_header::name_len"]
        [::std::mem::offset_of!(nwep_header, name_len) - 8usize];
    ["Offset of field: nwep_header::value"][::std::mem::offset_of!(nwep_header, value) - 16usize];
    ["Offset of field: nwep_header::value_len"]
        [::std::mem::offset_of!(nwep_header, value_len) - 24usize];
};
#[doc = " @struct\n\n :type:`nwep_msg` represents a parsed WEB/1 message."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_msg {
    #[doc = " :member:`type` is the message type (NWEP_MSG_REQUEST, etc.)."]
    pub type_: u8,
    #[doc = " :member:`headers` points to an array of headers."]
    pub headers: *mut nwep_header,
    #[doc = " :member:`header_count` is the number of headers."]
    pub header_count: usize,
    #[doc = " :member:`body` points to the message body."]
    pub body: *const u8,
    #[doc = " :member:`body_len` is the length of the body."]
    pub body_len: usize,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
#[cfg(all(target_pointer_width = "64", not(target_os = "windows")))]
const _: () = {
    ["Size of nwep_msg"][::std::mem::size_of::<nwep_msg>() - 40usize];
    ["Alignment of nwep_msg"][::std::mem::align_of::<nwep_msg>() - 8usize];
    ["Offset of field: nwep_msg::type_"][::std::mem::offset_of!(nwep_msg, type_) - 0usize];
    ["Offset of field: nwep_msg::headers"][::std::mem::offset_of!(nwep_msg, headers) - 8usize];
    ["Offset of field: nwep_msg::header_count"]
        [::std::mem::offset_of!(nwep_msg, header_count) - 16usize];
    ["Offset of field: nwep_msg::body"][::std::mem::offset_of!(nwep_msg, body) - 24usize];
    ["Offset of field: nwep_msg::body_len"][::std::mem::offset_of!(nwep_msg, body_len) - 32usize];
};
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_msg_init` initializes a message structure."]
    pub fn nwep_msg_init(msg: *mut nwep_msg, type_: u8);
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_msg_encode_len` calculates the encoded size of a message.\n This includes the 4-byte length prefix."]
    pub fn nwep_msg_encode_len(msg: *const nwep_msg) -> usize;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_msg_encode` encodes a message into a buffer.\n |dest| must have space for at least nwep_msg_encode_len() bytes.\n\n Returns the number of bytes written, or 0 on error."]
    pub fn nwep_msg_encode(dest: *mut u8, destlen: usize, msg: *const nwep_msg) -> usize;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_msg_decode_header` decodes just the frame header to get payload size.\n |src| must have at least NWEP_FRAME_HEADER_SIZE (4) bytes.\n |payload_len| receives the payload length (excludes the 4-byte header).\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_msg_decode_header(
        payload_len: *mut u32,
        src: *const u8,
        srclen: usize,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_msg_decode` decodes a complete message from a buffer.\n |src| must contain the complete message including the 4-byte length prefix.\n |msg| receives the decoded message. Headers point into |src| buffer.\n |headers| is a caller-provided array to store decoded headers.\n |max_headers| is the maximum number of headers to decode.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_msg_decode(
        msg: *mut nwep_msg,
        src: *const u8,
        srclen: usize,
        headers: *mut nwep_header,
        max_headers: usize,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_header_set` sets a header from C strings (null-terminated)."]
    pub fn nwep_header_set(
        hdr: *mut nwep_header,
        name: *const ::std::os::raw::c_char,
        value: *const ::std::os::raw::c_char,
    );
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_header_set_n` sets a header from byte arrays with lengths."]
    pub fn nwep_header_set_n(
        hdr: *mut nwep_header,
        name: *const u8,
        name_len: usize,
        value: *const u8,
        value_len: usize,
    );
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_msg_find_header` finds a header by name in a message.\n Returns a pointer to the header, or NULL if not found."]
    pub fn nwep_msg_find_header(
        msg: *const nwep_msg,
        name: *const ::std::os::raw::c_char,
    ) -> *const nwep_header;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_header_value_eq` returns nonzero if a header's value equals\n the given null-terminated string."]
    pub fn nwep_header_value_eq(
        hdr: *const nwep_header,
        value: *const ::std::os::raw::c_char,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_trace_id_generate` generates a 16-byte trace ID.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_trace_id_generate(trace_id: *mut u8) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_request_id_generate` generates a 16-byte request ID.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_request_id_generate(request_id: *mut u8) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_method_is_valid` checks if |method| is a valid WEB/1 method.\n\n Returns 1 if valid, 0 otherwise."]
    pub fn nwep_method_is_valid(method: *const ::std::os::raw::c_char) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_method_is_idempotent` checks if |method| is idempotent.\n Idempotent methods: READ, DELETE, HEARTBEAT.\n\n Returns 1 if idempotent, 0 otherwise."]
    pub fn nwep_method_is_idempotent(
        method: *const ::std::os::raw::c_char,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_method_allowed_0rtt` checks if |method| is allowed in 0-RTT.\n Only READ is allowed in 0-RTT for replay safety.\n\n Returns 1 if allowed, 0 otherwise."]
    pub fn nwep_method_allowed_0rtt(method: *const ::std::os::raw::c_char)
        -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_status_is_valid` checks if |status| is a valid WEB/1 status token.\n\n Returns 1 if valid, 0 otherwise."]
    pub fn nwep_status_is_valid(status: *const ::std::os::raw::c_char) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_status_is_success` checks if |status| indicates success.\n Success statuses: ok, created, accepted, no_content.\n\n Returns 1 if success, 0 otherwise."]
    pub fn nwep_status_is_success(status: *const ::std::os::raw::c_char) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_status_is_error` checks if |status| indicates an error.\n\n Returns 1 if error, 0 otherwise."]
    pub fn nwep_status_is_error(status: *const ::std::os::raw::c_char) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_request_build` builds a request message.\n |headers| must have space for at least 4 headers.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_request_build(
        msg: *mut nwep_msg,
        headers: *mut nwep_header,
        max_headers: usize,
        method: *const ::std::os::raw::c_char,
        path: *const ::std::os::raw::c_char,
        body: *const u8,
        body_len: usize,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_response_build` builds a response message.\n |headers| must have space for at least 2 headers.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_response_build(
        msg: *mut nwep_msg,
        headers: *mut nwep_header,
        max_headers: usize,
        status: *const ::std::os::raw::c_char,
        status_details: *const ::std::os::raw::c_char,
        body: *const u8,
        body_len: usize,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_stream_msg_build` builds a stream message for chunked body data.\n Stream messages have no headers, only body data.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_stream_msg_build(
        msg: *mut nwep_msg,
        data: *const u8,
        data_len: usize,
        is_final: ::std::os::raw::c_int,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_heartbeat_build` builds a HEARTBEAT request message.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_heartbeat_build(
        msg: *mut nwep_msg,
        headers: *mut nwep_header,
        max_headers: usize,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_heartbeat_response_build` builds a HEARTBEAT response message.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_heartbeat_response_build(
        msg: *mut nwep_msg,
        headers: *mut nwep_header,
        max_headers: usize,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_base64_encode_len` returns the buffer size needed to encode\n |srclen| bytes as Base64 (including null terminator)."]
    pub fn nwep_base64_encode_len(srclen: usize) -> usize;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_base64_encode` encodes |srclen| bytes from |src| into Base64.\n |dest| must have space for nwep_base64_encode_len(srclen) bytes.\n\n Returns the number of characters written (excluding null), or 0 on error."]
    pub fn nwep_base64_encode(
        dest: *mut ::std::os::raw::c_char,
        destlen: usize,
        src: *const u8,
        srclen: usize,
    ) -> usize;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_base64_decode_len` returns the maximum buffer size needed to decode\n a Base64 string of |srclen| characters."]
    pub fn nwep_base64_decode_len(srclen: usize) -> usize;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_base64_decode` decodes Base64 string |src| into |dest|.\n |src| must be null-terminated.\n\n Returns the number of bytes written, or 0 on error."]
    pub fn nwep_base64_decode(
        dest: *mut u8,
        destlen: usize,
        src: *const ::std::os::raw::c_char,
    ) -> usize;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_base64_decode_n` decodes |srclen| bytes of Base64 from |src| into\n |dest|. Unlike `nwep_base64_decode`, this function does not require |src|\n to be null-terminated.\n\n Returns the number of bytes written, or 0 on error."]
    pub fn nwep_base64_decode_n(
        dest: *mut u8,
        destlen: usize,
        src: *const ::std::os::raw::c_char,
        srclen: usize,
    ) -> usize;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_put_uint32be` writes a 32-bit big-endian value to |p|.\n Returns pointer past written bytes."]
    pub fn nwep_put_uint32be(p: *mut u8, n: u32) -> *mut u8;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_get_uint32be` reads a 32-bit big-endian value from |p|.\n Returns pointer past read bytes."]
    pub fn nwep_get_uint32be(dest: *mut u32, p: *const u8) -> *const u8;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_put_uint16be` writes a 16-bit big-endian value to |p|.\n Returns pointer past written bytes."]
    pub fn nwep_put_uint16be(p: *mut u8, n: u16) -> *mut u8;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_get_uint16be` reads a 16-bit big-endian value from |p|.\n Returns pointer past read bytes."]
    pub fn nwep_get_uint16be(dest: *mut u16, p: *const u8) -> *const u8;
}
pub const nwep_client_state_NWEP_CLIENT_STATE_INITIAL: nwep_client_state = 0;
pub const nwep_client_state_NWEP_CLIENT_STATE_TLS_HANDSHAKE: nwep_client_state = 1;
pub const nwep_client_state_NWEP_CLIENT_STATE_SEND_CONNECT: nwep_client_state = 2;
pub const nwep_client_state_NWEP_CLIENT_STATE_WAIT_CONNECT_RESP: nwep_client_state = 3;
pub const nwep_client_state_NWEP_CLIENT_STATE_SEND_AUTHENTICATE: nwep_client_state = 4;
pub const nwep_client_state_NWEP_CLIENT_STATE_WAIT_AUTH_RESP: nwep_client_state = 5;
pub const nwep_client_state_NWEP_CLIENT_STATE_CONNECTED: nwep_client_state = 6;
pub const nwep_client_state_NWEP_CLIENT_STATE_ERROR: nwep_client_state = 7;
#[doc = " @enum\n\n :type:`nwep_client_state` represents the client connection state machine."]
pub type nwep_client_state = ::std::os::raw::c_uint;
pub const nwep_server_state_NWEP_SERVER_STATE_INITIAL: nwep_server_state = 0;
pub const nwep_server_state_NWEP_SERVER_STATE_TLS_HANDSHAKE: nwep_server_state = 1;
pub const nwep_server_state_NWEP_SERVER_STATE_AWAITING_CONNECT: nwep_server_state = 2;
pub const nwep_server_state_NWEP_SERVER_STATE_AWAITING_CLIENT_AUTH: nwep_server_state = 3;
pub const nwep_server_state_NWEP_SERVER_STATE_CONNECTED: nwep_server_state = 4;
pub const nwep_server_state_NWEP_SERVER_STATE_ERROR: nwep_server_state = 5;
#[doc = " @enum\n\n :type:`nwep_server_state` represents the server connection state machine."]
pub type nwep_server_state = ::std::os::raw::c_uint;
#[doc = " @struct\n\n :type:`nwep_handshake_params` holds negotiable parameters for the handshake."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_handshake_params {
    pub max_streams: u32,
    pub max_message_size: u32,
    pub compression: *const ::std::os::raw::c_char,
    pub role: *const ::std::os::raw::c_char,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
#[cfg(all(target_pointer_width = "64", not(target_os = "windows")))]
const _: () = {
    ["Size of nwep_handshake_params"][::std::mem::size_of::<nwep_handshake_params>() - 24usize];
    ["Alignment of nwep_handshake_params"]
        [::std::mem::align_of::<nwep_handshake_params>() - 8usize];
    ["Offset of field: nwep_handshake_params::max_streams"]
        [::std::mem::offset_of!(nwep_handshake_params, max_streams) - 0usize];
    ["Offset of field: nwep_handshake_params::max_message_size"]
        [::std::mem::offset_of!(nwep_handshake_params, max_message_size) - 4usize];
    ["Offset of field: nwep_handshake_params::compression"]
        [::std::mem::offset_of!(nwep_handshake_params, compression) - 8usize];
    ["Offset of field: nwep_handshake_params::role"]
        [::std::mem::offset_of!(nwep_handshake_params, role) - 16usize];
};
#[doc = " @struct\n\n :type:`nwep_handshake` holds the state for a CONNECT/AUTHENTICATE handshake."]
#[repr(C)]
#[derive(Copy, Clone)]
pub struct nwep_handshake {
    pub local_keypair: *mut nwep_keypair,
    pub local_nodeid: nwep_nodeid,
    pub peer_pubkey: [u8; 32usize],
    pub peer_nodeid: nwep_nodeid,
    pub expected_peer_nodeid: nwep_nodeid,
    pub peer_nodeid_verified: ::std::os::raw::c_int,
    pub local_challenge: [u8; 32usize],
    pub peer_challenge: [u8; 32usize],
    pub local_params: nwep_handshake_params,
    pub peer_params: nwep_handshake_params,
    pub negotiated_params: nwep_handshake_params,
    pub transcript: *mut u8,
    pub transcript_len: usize,
    pub transcript_cap: usize,
    pub is_server: ::std::os::raw::c_int,
    pub state: nwep_handshake__bindgen_ty_1,
    pub error_code: ::std::os::raw::c_int,
}
#[repr(C)]
#[derive(Copy, Clone)]
pub union nwep_handshake__bindgen_ty_1 {
    pub client: nwep_client_state,
    pub server: nwep_server_state,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
#[cfg(all(target_pointer_width = "64", not(target_os = "windows")))]
const _: () = {
    ["Size of nwep_handshake__bindgen_ty_1"]
        [::std::mem::size_of::<nwep_handshake__bindgen_ty_1>() - 4usize];
    ["Alignment of nwep_handshake__bindgen_ty_1"]
        [::std::mem::align_of::<nwep_handshake__bindgen_ty_1>() - 4usize];
    ["Offset of field: nwep_handshake__bindgen_ty_1::client"]
        [::std::mem::offset_of!(nwep_handshake__bindgen_ty_1, client) - 0usize];
    ["Offset of field: nwep_handshake__bindgen_ty_1::server"]
        [::std::mem::offset_of!(nwep_handshake__bindgen_ty_1, server) - 0usize];
};
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
#[cfg(all(target_pointer_width = "64", not(target_os = "windows")))]
const _: () = {
    ["Size of nwep_handshake"][::std::mem::size_of::<nwep_handshake>() - 320usize];
    ["Alignment of nwep_handshake"][::std::mem::align_of::<nwep_handshake>() - 8usize];
    ["Offset of field: nwep_handshake::local_keypair"]
        [::std::mem::offset_of!(nwep_handshake, local_keypair) - 0usize];
    ["Offset of field: nwep_handshake::local_nodeid"]
        [::std::mem::offset_of!(nwep_handshake, local_nodeid) - 8usize];
    ["Offset of field: nwep_handshake::peer_pubkey"]
        [::std::mem::offset_of!(nwep_handshake, peer_pubkey) - 40usize];
    ["Offset of field: nwep_handshake::peer_nodeid"]
        [::std::mem::offset_of!(nwep_handshake, peer_nodeid) - 72usize];
    ["Offset of field: nwep_handshake::expected_peer_nodeid"]
        [::std::mem::offset_of!(nwep_handshake, expected_peer_nodeid) - 104usize];
    ["Offset of field: nwep_handshake::peer_nodeid_verified"]
        [::std::mem::offset_of!(nwep_handshake, peer_nodeid_verified) - 136usize];
    ["Offset of field: nwep_handshake::local_challenge"]
        [::std::mem::offset_of!(nwep_handshake, local_challenge) - 140usize];
    ["Offset of field: nwep_handshake::peer_challenge"]
        [::std::mem::offset_of!(nwep_handshake, peer_challenge) - 172usize];
    ["Offset of field: nwep_handshake::local_params"]
        [::std::mem::offset_of!(nwep_handshake, local_params) - 208usize];
    ["Offset of field: nwep_handshake::peer_params"]
        [::std::mem::offset_of!(nwep_handshake, peer_params) - 232usize];
    ["Offset of field: nwep_handshake::negotiated_params"]
        [::std::mem::offset_of!(nwep_handshake, negotiated_params) - 256usize];
    ["Offset of field: nwep_handshake::transcript"]
        [::std::mem::offset_of!(nwep_handshake, transcript) - 280usize];
    ["Offset of field: nwep_handshake::transcript_len"]
        [::std::mem::offset_of!(nwep_handshake, transcript_len) - 288usize];
    ["Offset of field: nwep_handshake::transcript_cap"]
        [::std::mem::offset_of!(nwep_handshake, transcript_cap) - 296usize];
    ["Offset of field: nwep_handshake::is_server"]
        [::std::mem::offset_of!(nwep_handshake, is_server) - 304usize];
    ["Offset of field: nwep_handshake::state"]
        [::std::mem::offset_of!(nwep_handshake, state) - 308usize];
    ["Offset of field: nwep_handshake::error_code"]
        [::std::mem::offset_of!(nwep_handshake, error_code) - 312usize];
};
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_handshake_client_init` initializes a client handshake context.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_handshake_client_init(
        hs: *mut nwep_handshake,
        keypair: *mut nwep_keypair,
        expected_server: *const nwep_nodeid,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_handshake_server_init` initializes a server handshake context.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_handshake_server_init(
        hs: *mut nwep_handshake,
        keypair: *mut nwep_keypair,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_handshake_free` frees resources allocated for a handshake."]
    pub fn nwep_handshake_free(hs: *mut nwep_handshake);
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_handshake_set_params` sets the local handshake parameters."]
    pub fn nwep_handshake_set_params(hs: *mut nwep_handshake, params: *const nwep_handshake_params);
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_connect_request_build` builds a CONNECT request message.\n |headers| must have space for at least 6 headers.\n |header_buf| is scratch space for Base64-encoded values.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_connect_request_build(
        msg: *mut nwep_msg,
        headers: *mut nwep_header,
        max_headers: usize,
        header_buf: *mut u8,
        header_buf_len: usize,
        hs: *mut nwep_handshake,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_connect_request_parse` parses a CONNECT request and updates handshake state.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_connect_request_parse(
        hs: *mut nwep_handshake,
        msg: *const nwep_msg,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_connect_response_build` builds a CONNECT response message.\n |headers| must have space for at least 10 headers.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_connect_response_build(
        msg: *mut nwep_msg,
        headers: *mut nwep_header,
        max_headers: usize,
        header_buf: *mut u8,
        header_buf_len: usize,
        hs: *mut nwep_handshake,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_connect_response_parse` parses a CONNECT response and verifies server.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_connect_response_parse(
        hs: *mut nwep_handshake,
        msg: *const nwep_msg,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_auth_request_build` builds an AUTHENTICATE request message.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_auth_request_build(
        msg: *mut nwep_msg,
        headers: *mut nwep_header,
        max_headers: usize,
        header_buf: *mut u8,
        header_buf_len: usize,
        hs: *mut nwep_handshake,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_auth_request_parse` parses an AUTHENTICATE request and verifies client.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_auth_request_parse(
        hs: *mut nwep_handshake,
        msg: *const nwep_msg,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_auth_response_build` builds an AUTHENTICATE response message.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_auth_response_build(
        msg: *mut nwep_msg,
        headers: *mut nwep_header,
        max_headers: usize,
        hs: *mut nwep_handshake,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_auth_response_parse` parses an AUTHENTICATE response.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_auth_response_parse(
        hs: *mut nwep_handshake,
        msg: *const nwep_msg,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_verify_layer1` verifies Layer 1: TLS cert pubkey matches peer_pubkey.\n |tls_pubkey| is extracted from the peer's TLS certificate.\n\n Returns 0 if valid, or NWEP_ERR_CRYPTO_PUBKEY_MISMATCH."]
    pub fn nwep_verify_layer1(
        hs: *const nwep_handshake,
        tls_pubkey: *const u8,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_verify_layer2` verifies Layer 2: NodeID derivation is correct.\n Checks that SHA-256(peer_pubkey || \"WEB/1\") == expected_peer_nodeid.\n\n Returns 0 if valid, or NWEP_ERR_CRYPTO_NODEID_MISMATCH."]
    pub fn nwep_verify_layer2(hs: *const nwep_handshake) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_verify_layer3` verifies Layer 3: challenge signature is valid.\n |signature| is the peer's response to our challenge.\n\n Returns 0 if valid, or NWEP_ERR_CRYPTO_CHALLENGE_FAILED."]
    pub fn nwep_verify_layer3(
        hs: *const nwep_handshake,
        signature: *const u8,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_verify_all_layers` performs all three verification layers.\n\n Returns 0 if all valid, or the first fatal error encountered."]
    pub fn nwep_verify_all_layers(
        hs: *const nwep_handshake,
        tls_pubkey: *const u8,
        signature: *const u8,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_transcript_init` initializes the transcript buffer.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_transcript_init(hs: *mut nwep_handshake) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_transcript_add_connect_request` adds CONNECT request to transcript.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_transcript_add_connect_request(hs: *mut nwep_handshake) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_transcript_add_connect_response` adds CONNECT response to transcript.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_transcript_add_connect_response(hs: *mut nwep_handshake) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_transcript_sign` signs the transcript and returns the signature.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_transcript_sign(
        signature: *mut u8,
        hs: *const nwep_handshake,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_transcript_verify` verifies a transcript signature from the peer.\n\n Returns 0 if valid, or a negative error code."]
    pub fn nwep_transcript_verify(
        hs: *const nwep_handshake,
        signature: *const u8,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_client_state_str` returns a string representation of the client state."]
    pub fn nwep_client_state_str(state: nwep_client_state) -> *const ::std::os::raw::c_char;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_server_state_str` returns a string representation of the server state."]
    pub fn nwep_server_state_str(state: nwep_server_state) -> *const ::std::os::raw::c_char;
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_server {
    _unused: [u8; 0],
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_client {
    _unused: [u8; 0],
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_conn {
    _unused: [u8; 0],
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_stream {
    _unused: [u8; 0],
}
pub const nwep_log_level_NWEP_LOG_TRACE: nwep_log_level = 0;
pub const nwep_log_level_NWEP_LOG_DEBUG: nwep_log_level = 1;
pub const nwep_log_level_NWEP_LOG_INFO: nwep_log_level = 2;
pub const nwep_log_level_NWEP_LOG_WARN: nwep_log_level = 3;
pub const nwep_log_level_NWEP_LOG_ERROR: nwep_log_level = 4;
#[doc = " @enum\n\n :type:`nwep_log_level` defines logging severity levels."]
pub type nwep_log_level = ::std::os::raw::c_uint;
#[doc = " @struct\n\n :type:`nwep_log_entry` represents a structured log entry."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_log_entry {
    #[doc = " :member:`level` is the log severity level."]
    pub level: nwep_log_level,
    #[doc = " :member:`timestamp_ns` is the timestamp in nanoseconds (optional, 0 if not set)."]
    pub timestamp_ns: u64,
    #[doc = " :member:`trace_id` is the 16-byte trace ID (all zeros if not set)."]
    pub trace_id: [u8; 16usize],
    #[doc = " :member:`component` is the component name (e.g., \"handshake\", \"stream\")."]
    pub component: *const ::std::os::raw::c_char,
    #[doc = " :member:`message` is the log message."]
    pub message: *const ::std::os::raw::c_char,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
#[cfg(all(target_pointer_width = "64", not(target_os = "windows")))]
const _: () = {
    ["Size of nwep_log_entry"][::std::mem::size_of::<nwep_log_entry>() - 48usize];
    ["Alignment of nwep_log_entry"][::std::mem::align_of::<nwep_log_entry>() - 8usize];
    ["Offset of field: nwep_log_entry::level"]
        [::std::mem::offset_of!(nwep_log_entry, level) - 0usize];
    ["Offset of field: nwep_log_entry::timestamp_ns"]
        [::std::mem::offset_of!(nwep_log_entry, timestamp_ns) - 8usize];
    ["Offset of field: nwep_log_entry::trace_id"]
        [::std::mem::offset_of!(nwep_log_entry, trace_id) - 16usize];
    ["Offset of field: nwep_log_entry::component"]
        [::std::mem::offset_of!(nwep_log_entry, component) - 32usize];
    ["Offset of field: nwep_log_entry::message"]
        [::std::mem::offset_of!(nwep_log_entry, message) - 40usize];
};
#[doc = " @callback\n\n `nwep_log_callback` is called for each log entry when using custom logging."]
pub type nwep_log_callback = ::std::option::Option<
    unsafe extern "C" fn(entry: *const nwep_log_entry, user_data: *mut ::std::os::raw::c_void),
>;
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_log_level_str` returns the string representation of a log level."]
    pub fn nwep_log_level_str(level: nwep_log_level) -> *const ::std::os::raw::c_char;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_log_set_level` sets the minimum log level for output.\n Messages below this level are discarded."]
    pub fn nwep_log_set_level(level: nwep_log_level);
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_log_get_level` returns the current minimum log level."]
    pub fn nwep_log_get_level() -> nwep_log_level;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_log_set_callback` sets a custom log callback function.\n If set, all log output goes to the callback instead of default output."]
    pub fn nwep_log_set_callback(
        callback: nwep_log_callback,
        user_data: *mut ::std::os::raw::c_void,
    );
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_log_set_json` enables or disables JSON format output.\n Default is plain text format."]
    pub fn nwep_log_set_json(enabled: ::std::os::raw::c_int);
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_log_set_stderr` enables or disables stderr output.\n Default is enabled. Disable when using a custom callback."]
    pub fn nwep_log_set_stderr(enabled: ::std::os::raw::c_int);
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_log_write` writes a log entry with the specified level, trace ID,\n component, and printf-style message."]
    pub fn nwep_log_write(
        level: nwep_log_level,
        trace_id: *const u8,
        component: *const ::std::os::raw::c_char,
        fmt: *const ::std::os::raw::c_char,
        ...
    );
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_log_trace` writes a TRACE level log entry."]
    pub fn nwep_log_trace(
        trace_id: *const u8,
        component: *const ::std::os::raw::c_char,
        fmt: *const ::std::os::raw::c_char,
        ...
    );
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_log_debug` writes a DEBUG level log entry."]
    pub fn nwep_log_debug(
        trace_id: *const u8,
        component: *const ::std::os::raw::c_char,
        fmt: *const ::std::os::raw::c_char,
        ...
    );
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_log_info` writes an INFO level log entry."]
    pub fn nwep_log_info(
        trace_id: *const u8,
        component: *const ::std::os::raw::c_char,
        fmt: *const ::std::os::raw::c_char,
        ...
    );
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_log_warn` writes a WARN level log entry."]
    pub fn nwep_log_warn(
        trace_id: *const u8,
        component: *const ::std::os::raw::c_char,
        fmt: *const ::std::os::raw::c_char,
        ...
    );
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_log_error` writes an ERROR level log entry."]
    pub fn nwep_log_error(
        trace_id: *const u8,
        component: *const ::std::os::raw::c_char,
        fmt: *const ::std::os::raw::c_char,
        ...
    );
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_log_format_json` formats a log entry as a JSON string.\n Returns the number of bytes written (excluding null terminator)."]
    pub fn nwep_log_format_json(
        dest: *mut ::std::os::raw::c_char,
        destlen: usize,
        entry: *const nwep_log_entry,
    ) -> usize;
}
#[doc = " @struct\n\n :type:`nwep_identity` holds identity information (pubkey and NodeID)."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_identity {
    pub pubkey: [u8; 32usize],
    pub nodeid: nwep_nodeid,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
#[cfg(all(target_pointer_width = "64", not(target_os = "windows")))]
const _: () = {
    ["Size of nwep_identity"][::std::mem::size_of::<nwep_identity>() - 64usize];
    ["Alignment of nwep_identity"][::std::mem::align_of::<nwep_identity>() - 1usize];
    ["Offset of field: nwep_identity::pubkey"]
        [::std::mem::offset_of!(nwep_identity, pubkey) - 0usize];
    ["Offset of field: nwep_identity::nodeid"]
        [::std::mem::offset_of!(nwep_identity, nodeid) - 32usize];
};
#[doc = " @struct\n\n :type:`nwep_request` represents an incoming request."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_request {
    pub method: *const ::std::os::raw::c_char,
    pub method_len: usize,
    pub path: *const ::std::os::raw::c_char,
    pub path_len: usize,
    pub headers: *const nwep_header,
    pub header_count: usize,
    pub body: *const u8,
    pub body_len: usize,
    pub request_id: [u8; 16usize],
    pub trace_id: [u8; 16usize],
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
#[cfg(all(target_pointer_width = "64", not(target_os = "windows")))]
const _: () = {
    ["Size of nwep_request"][::std::mem::size_of::<nwep_request>() - 96usize];
    ["Alignment of nwep_request"][::std::mem::align_of::<nwep_request>() - 8usize];
    ["Offset of field: nwep_request::method"]
        [::std::mem::offset_of!(nwep_request, method) - 0usize];
    ["Offset of field: nwep_request::method_len"]
        [::std::mem::offset_of!(nwep_request, method_len) - 8usize];
    ["Offset of field: nwep_request::path"][::std::mem::offset_of!(nwep_request, path) - 16usize];
    ["Offset of field: nwep_request::path_len"]
        [::std::mem::offset_of!(nwep_request, path_len) - 24usize];
    ["Offset of field: nwep_request::headers"]
        [::std::mem::offset_of!(nwep_request, headers) - 32usize];
    ["Offset of field: nwep_request::header_count"]
        [::std::mem::offset_of!(nwep_request, header_count) - 40usize];
    ["Offset of field: nwep_request::body"][::std::mem::offset_of!(nwep_request, body) - 48usize];
    ["Offset of field: nwep_request::body_len"]
        [::std::mem::offset_of!(nwep_request, body_len) - 56usize];
    ["Offset of field: nwep_request::request_id"]
        [::std::mem::offset_of!(nwep_request, request_id) - 64usize];
    ["Offset of field: nwep_request::trace_id"]
        [::std::mem::offset_of!(nwep_request, trace_id) - 80usize];
};
#[doc = " @struct\n\n :type:`nwep_response` represents an incoming or outgoing response."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_response {
    pub status: *const ::std::os::raw::c_char,
    pub status_len: usize,
    pub status_details: *const ::std::os::raw::c_char,
    pub status_details_len: usize,
    pub headers: *const nwep_header,
    pub header_count: usize,
    pub body: *const u8,
    pub body_len: usize,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
#[cfg(all(target_pointer_width = "64", not(target_os = "windows")))]
const _: () = {
    ["Size of nwep_response"][::std::mem::size_of::<nwep_response>() - 64usize];
    ["Alignment of nwep_response"][::std::mem::align_of::<nwep_response>() - 8usize];
    ["Offset of field: nwep_response::status"]
        [::std::mem::offset_of!(nwep_response, status) - 0usize];
    ["Offset of field: nwep_response::status_len"]
        [::std::mem::offset_of!(nwep_response, status_len) - 8usize];
    ["Offset of field: nwep_response::status_details"]
        [::std::mem::offset_of!(nwep_response, status_details) - 16usize];
    ["Offset of field: nwep_response::status_details_len"]
        [::std::mem::offset_of!(nwep_response, status_details_len) - 24usize];
    ["Offset of field: nwep_response::headers"]
        [::std::mem::offset_of!(nwep_response, headers) - 32usize];
    ["Offset of field: nwep_response::header_count"]
        [::std::mem::offset_of!(nwep_response, header_count) - 40usize];
    ["Offset of field: nwep_response::body"][::std::mem::offset_of!(nwep_response, body) - 48usize];
    ["Offset of field: nwep_response::body_len"]
        [::std::mem::offset_of!(nwep_response, body_len) - 56usize];
};
#[doc = " @struct\n\n :type:`nwep_notify` represents a server-initiated notification."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_notify {
    pub event: *const ::std::os::raw::c_char,
    pub event_len: usize,
    pub path: *const ::std::os::raw::c_char,
    pub path_len: usize,
    pub notify_id: [u8; 16usize],
    pub has_notify_id: ::std::os::raw::c_int,
    pub headers: *const nwep_header,
    pub header_count: usize,
    pub body: *const u8,
    pub body_len: usize,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
#[cfg(all(target_pointer_width = "64", not(target_os = "windows")))]
const _: () = {
    ["Size of nwep_notify"][::std::mem::size_of::<nwep_notify>() - 88usize];
    ["Alignment of nwep_notify"][::std::mem::align_of::<nwep_notify>() - 8usize];
    ["Offset of field: nwep_notify::event"][::std::mem::offset_of!(nwep_notify, event) - 0usize];
    ["Offset of field: nwep_notify::event_len"]
        [::std::mem::offset_of!(nwep_notify, event_len) - 8usize];
    ["Offset of field: nwep_notify::path"][::std::mem::offset_of!(nwep_notify, path) - 16usize];
    ["Offset of field: nwep_notify::path_len"]
        [::std::mem::offset_of!(nwep_notify, path_len) - 24usize];
    ["Offset of field: nwep_notify::notify_id"]
        [::std::mem::offset_of!(nwep_notify, notify_id) - 32usize];
    ["Offset of field: nwep_notify::has_notify_id"]
        [::std::mem::offset_of!(nwep_notify, has_notify_id) - 48usize];
    ["Offset of field: nwep_notify::headers"]
        [::std::mem::offset_of!(nwep_notify, headers) - 56usize];
    ["Offset of field: nwep_notify::header_count"]
        [::std::mem::offset_of!(nwep_notify, header_count) - 64usize];
    ["Offset of field: nwep_notify::body"][::std::mem::offset_of!(nwep_notify, body) - 72usize];
    ["Offset of field: nwep_notify::body_len"]
        [::std::mem::offset_of!(nwep_notify, body_len) - 80usize];
};
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_request_parse` parses a decoded message into a request structure.\n |msg| must be a NWEP_MSG_REQUEST type message.\n\n Returns 0 on success, or one of the following negative error codes:\n\n :macro:`NWEP_ERR_PROTO_INVALID_MESSAGE`\n     Message is not a request.\n :macro:`NWEP_ERR_PROTO_MISSING_HEADER`\n     Required header is missing.\n :macro:`NWEP_ERR_PROTO_INVALID_METHOD`\n     Method is not valid."]
    pub fn nwep_request_parse(
        req: *mut nwep_request,
        msg: *const nwep_msg,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_response_parse` parses a decoded message into a response structure.\n |msg| must be a NWEP_MSG_RESPONSE type message.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_response_parse(
        resp: *mut nwep_response,
        msg: *const nwep_msg,
    ) -> ::std::os::raw::c_int;
}
#[doc = " @callback\n\n `nwep_on_connect` is called when a connection is established.\n |peer| contains the peer's identity.\n\n Return 0 to accept the connection, or a negative error code to reject."]
pub type nwep_on_connect = ::std::option::Option<
    unsafe extern "C" fn(
        conn: *mut nwep_conn,
        peer: *const nwep_identity,
        user_data: *mut ::std::os::raw::c_void,
    ) -> ::std::os::raw::c_int,
>;
#[doc = " @callback\n\n `nwep_on_disconnect` is called when a connection is closed.\n |error| is the error that caused the disconnect (0 for graceful close)."]
pub type nwep_on_disconnect = ::std::option::Option<
    unsafe extern "C" fn(
        conn: *mut nwep_conn,
        error: ::std::os::raw::c_int,
        user_data: *mut ::std::os::raw::c_void,
    ),
>;
#[doc = " @callback\n\n `nwep_on_request` is called when a request is received (server-side).\n The callback should call nwep_stream_respond() to send a response.\n\n Return 0 on success, or a negative error code."]
pub type nwep_on_request = ::std::option::Option<
    unsafe extern "C" fn(
        conn: *mut nwep_conn,
        stream: *mut nwep_stream,
        req: *const nwep_request,
        user_data: *mut ::std::os::raw::c_void,
    ) -> ::std::os::raw::c_int,
>;
#[doc = " @callback\n\n `nwep_on_response` is called when a response is received (client-side).\n\n Return 0 on success, or a negative error code."]
pub type nwep_on_response = ::std::option::Option<
    unsafe extern "C" fn(
        conn: *mut nwep_conn,
        stream: *mut nwep_stream,
        resp: *const nwep_response,
        user_data: *mut ::std::os::raw::c_void,
    ) -> ::std::os::raw::c_int,
>;
#[doc = " @callback\n\n `nwep_on_stream_data` is called when stream body data is received.\n\n Return 0 on success, or a negative error code."]
pub type nwep_on_stream_data = ::std::option::Option<
    unsafe extern "C" fn(
        conn: *mut nwep_conn,
        stream: *mut nwep_stream,
        data: *const u8,
        len: usize,
        user_data: *mut ::std::os::raw::c_void,
    ) -> ::std::os::raw::c_int,
>;
#[doc = " @callback\n\n `nwep_on_stream_end` is called when the stream ends (FIN received).\n\n Return 0 on success, or a negative error code."]
pub type nwep_on_stream_end = ::std::option::Option<
    unsafe extern "C" fn(
        conn: *mut nwep_conn,
        stream: *mut nwep_stream,
        user_data: *mut ::std::os::raw::c_void,
    ) -> ::std::os::raw::c_int,
>;
#[doc = " @callback\n\n `nwep_on_notify` is called when a NOTIFY is received (client-side).\n\n Return 0 on success, or a negative error code."]
pub type nwep_on_notify = ::std::option::Option<
    unsafe extern "C" fn(
        conn: *mut nwep_conn,
        stream: *mut nwep_stream,
        notify: *const nwep_notify,
        user_data: *mut ::std::os::raw::c_void,
    ) -> ::std::os::raw::c_int,
>;
#[doc = " @callback\n\n `nwep_rand` generates random bytes. If not provided, OpenSSL's\n RAND_bytes will be used.\n\n Return 0 on success, or a negative error code."]
pub type nwep_rand = ::std::option::Option<
    unsafe extern "C" fn(
        dest: *mut u8,
        len: usize,
        user_data: *mut ::std::os::raw::c_void,
    ) -> ::std::os::raw::c_int,
>;
#[doc = " @struct\n\n :type:`nwep_callbacks` holds all callback function pointers."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_callbacks {
    pub on_connect: nwep_on_connect,
    pub on_disconnect: nwep_on_disconnect,
    pub on_request: nwep_on_request,
    pub on_response: nwep_on_response,
    pub on_notify: nwep_on_notify,
    pub on_stream_data: nwep_on_stream_data,
    pub on_stream_end: nwep_on_stream_end,
    pub rand: nwep_rand,
    pub log: nwep_log_callback,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
#[cfg(all(target_pointer_width = "64", not(target_os = "windows")))]
const _: () = {
    ["Size of nwep_callbacks"][::std::mem::size_of::<nwep_callbacks>() - 72usize];
    ["Alignment of nwep_callbacks"][::std::mem::align_of::<nwep_callbacks>() - 8usize];
    ["Offset of field: nwep_callbacks::on_connect"]
        [::std::mem::offset_of!(nwep_callbacks, on_connect) - 0usize];
    ["Offset of field: nwep_callbacks::on_disconnect"]
        [::std::mem::offset_of!(nwep_callbacks, on_disconnect) - 8usize];
    ["Offset of field: nwep_callbacks::on_request"]
        [::std::mem::offset_of!(nwep_callbacks, on_request) - 16usize];
    ["Offset of field: nwep_callbacks::on_response"]
        [::std::mem::offset_of!(nwep_callbacks, on_response) - 24usize];
    ["Offset of field: nwep_callbacks::on_notify"]
        [::std::mem::offset_of!(nwep_callbacks, on_notify) - 32usize];
    ["Offset of field: nwep_callbacks::on_stream_data"]
        [::std::mem::offset_of!(nwep_callbacks, on_stream_data) - 40usize];
    ["Offset of field: nwep_callbacks::on_stream_end"]
        [::std::mem::offset_of!(nwep_callbacks, on_stream_end) - 48usize];
    ["Offset of field: nwep_callbacks::rand"]
        [::std::mem::offset_of!(nwep_callbacks, rand) - 56usize];
    ["Offset of field: nwep_callbacks::log"][::std::mem::offset_of!(nwep_callbacks, log) - 64usize];
};
#[doc = " @struct\n\n :type:`nwep_settings` holds configuration settings."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_settings {
    #[doc = " :member:`max_streams` is the maximum concurrent streams (default 100)."]
    pub max_streams: u32,
    #[doc = " :member:`max_message_size` is the maximum message size (default 24MB)."]
    pub max_message_size: u32,
    #[doc = " :member:`timeout_ms` is the connection timeout in milliseconds (default 30000)."]
    pub timeout_ms: u32,
    #[doc = " :member:`compression` is the compression algorithm (\"none\" or \"zstd\")."]
    pub compression: *const ::std::os::raw::c_char,
    #[doc = " :member:`role` is the advertised role (server only, e.g., \"regular_node\")."]
    pub role: *const ::std::os::raw::c_char,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
#[cfg(all(target_pointer_width = "64", not(target_os = "windows")))]
const _: () = {
    ["Size of nwep_settings"][::std::mem::size_of::<nwep_settings>() - 32usize];
    ["Alignment of nwep_settings"][::std::mem::align_of::<nwep_settings>() - 8usize];
    ["Offset of field: nwep_settings::max_streams"]
        [::std::mem::offset_of!(nwep_settings, max_streams) - 0usize];
    ["Offset of field: nwep_settings::max_message_size"]
        [::std::mem::offset_of!(nwep_settings, max_message_size) - 4usize];
    ["Offset of field: nwep_settings::timeout_ms"]
        [::std::mem::offset_of!(nwep_settings, timeout_ms) - 8usize];
    ["Offset of field: nwep_settings::compression"]
        [::std::mem::offset_of!(nwep_settings, compression) - 16usize];
    ["Offset of field: nwep_settings::role"][::std::mem::offset_of!(nwep_settings, role) - 24usize];
};
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_settings_default` initializes settings with default values."]
    pub fn nwep_settings_default(settings: *mut nwep_settings);
}
#[doc = " @struct\n\n :type:`nwep_path` represents a network path (local and remote addresses)."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_path {
    pub local_addr: sockaddr_storage,
    pub local_addrlen: usize,
    pub remote_addr: sockaddr_storage,
    pub remote_addrlen: usize,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
#[cfg(all(target_pointer_width = "64", not(target_os = "windows")))]
const _: () = {
    ["Size of nwep_path"][::std::mem::size_of::<nwep_path>() - 272usize];
    ["Alignment of nwep_path"][::std::mem::align_of::<nwep_path>() - 8usize];
    ["Offset of field: nwep_path::local_addr"]
        [::std::mem::offset_of!(nwep_path, local_addr) - 0usize];
    ["Offset of field: nwep_path::local_addrlen"]
        [::std::mem::offset_of!(nwep_path, local_addrlen) - 128usize];
    ["Offset of field: nwep_path::remote_addr"]
        [::std::mem::offset_of!(nwep_path, remote_addr) - 136usize];
    ["Offset of field: nwep_path::remote_addrlen"]
        [::std::mem::offset_of!(nwep_path, remote_addrlen) - 264usize];
};
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_init` initializes the nwep library.\n Call this function before using any other nwep functions.\n This initializes the underlying TLS/crypto library.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_init() -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_server_new` creates a new server instance.\n |keypair| is the server's Ed25519 keypair (caller retains ownership).\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_server_new(
        pserver: *mut *mut nwep_server,
        settings: *const nwep_settings,
        callbacks: *const nwep_callbacks,
        keypair: *mut nwep_keypair,
        user_data: *mut ::std::os::raw::c_void,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_server_free` frees a server instance."]
    pub fn nwep_server_free(server: *mut nwep_server);
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_server_read` processes a received packet.\n |path| identifies the network path the packet arrived on.\n |data| is the packet data, |datalen| is its length.\n |ts| is the current timestamp in nanoseconds.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_server_read(
        server: *mut nwep_server,
        path: *const nwep_path,
        data: *const u8,
        datalen: usize,
        ts: nwep_tstamp,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_server_write` gets the next packet to send.\n |path| receives the network path to send on.\n |data| is the buffer to write to, |datalen| is its capacity.\n |ts| is the current timestamp in nanoseconds.\n\n Returns the number of bytes written, 0 if no packet to send,\n or a negative error code."]
    pub fn nwep_server_write(
        server: *mut nwep_server,
        path: *mut nwep_path,
        data: *mut u8,
        datalen: usize,
        ts: nwep_tstamp,
    ) -> nwep_ssize;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_server_handle_expiry` handles timer expiration.\n Call this when the timer returned by nwep_server_get_expiry() fires.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_server_handle_expiry(
        server: *mut nwep_server,
        ts: nwep_tstamp,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_server_get_expiry` gets the next timer deadline.\n\n Returns the deadline in nanoseconds, or UINT64_MAX if no timer is set."]
    pub fn nwep_server_get_expiry(server: *const nwep_server) -> nwep_tstamp;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_server_close` initiates graceful shutdown."]
    pub fn nwep_server_close(server: *mut nwep_server);
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_client_new` creates a new client instance.\n |keypair| is the client's Ed25519 keypair (caller retains ownership).\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_client_new(
        pclient: *mut *mut nwep_client,
        settings: *const nwep_settings,
        callbacks: *const nwep_callbacks,
        keypair: *mut nwep_keypair,
        user_data: *mut ::std::os::raw::c_void,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_client_free` frees a client instance."]
    pub fn nwep_client_free(client: *mut nwep_client);
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_client_connect` initiates a connection to a web:// address.\n |url| is the parsed URL containing address and path.\n |local_addr| is the local address to bind to (can be NULL).\n |ts| is the current timestamp in nanoseconds.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_client_connect(
        client: *mut nwep_client,
        url: *const nwep_url,
        local_addr: *const sockaddr,
        local_addrlen: usize,
        ts: nwep_tstamp,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_client_read` processes a received packet.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_client_read(
        client: *mut nwep_client,
        path: *const nwep_path,
        data: *const u8,
        datalen: usize,
        ts: nwep_tstamp,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_client_write` gets the next packet to send.\n\n Returns the number of bytes written, 0 if no packet to send,\n or a negative error code."]
    pub fn nwep_client_write(
        client: *mut nwep_client,
        path: *mut nwep_path,
        data: *mut u8,
        datalen: usize,
        ts: nwep_tstamp,
    ) -> nwep_ssize;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_client_handle_expiry` handles timer expiration.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_client_handle_expiry(
        client: *mut nwep_client,
        ts: nwep_tstamp,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_client_get_expiry` gets the next timer deadline.\n\n Returns the deadline in nanoseconds, or UINT64_MAX if no timer is set."]
    pub fn nwep_client_get_expiry(client: *const nwep_client) -> nwep_tstamp;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_client_close` initiates graceful shutdown."]
    pub fn nwep_client_close(client: *mut nwep_client);
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_client_get_conn` gets the connection for the client.\n Returns NULL if not connected."]
    pub fn nwep_client_get_conn(client: *mut nwep_client) -> *mut nwep_conn;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_conn_get_peer_identity` gets the peer's identity."]
    pub fn nwep_conn_get_peer_identity(conn: *const nwep_conn) -> *const nwep_identity;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_conn_get_local_identity` gets our identity."]
    pub fn nwep_conn_get_local_identity(conn: *const nwep_conn) -> *const nwep_identity;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_conn_get_role` gets the negotiated role."]
    pub fn nwep_conn_get_role(conn: *const nwep_conn) -> *const ::std::os::raw::c_char;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_conn_close` closes the connection with an error.\n |error| is the error code (0 for graceful close)."]
    pub fn nwep_conn_close(conn: *mut nwep_conn, error: ::std::os::raw::c_int);
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_conn_get_user_data` gets the user data associated with the connection."]
    pub fn nwep_conn_get_user_data(conn: *const nwep_conn) -> *mut ::std::os::raw::c_void;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_conn_set_user_data` sets user data for the connection."]
    pub fn nwep_conn_set_user_data(conn: *mut nwep_conn, user_data: *mut ::std::os::raw::c_void);
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_stream_request` sends a request and returns the stream.\n |req| contains the request to send.\n |pstream| receives the stream pointer for response handling.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_stream_request(
        conn: *mut nwep_conn,
        req: *const nwep_request,
        pstream: *mut *mut nwep_stream,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_stream_respond` sends a response on a stream (server-side).\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_stream_respond(
        stream: *mut nwep_stream,
        resp: *const nwep_response,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_stream_write` writes body data to a stream.\n\n Returns the number of bytes written, or a negative error code."]
    pub fn nwep_stream_write(stream: *mut nwep_stream, data: *const u8, len: usize) -> nwep_ssize;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_stream_end` signals the end of the stream (sends FIN).\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_stream_end(stream: *mut nwep_stream) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_stream_close` closes the stream with an error (sends RESET)."]
    pub fn nwep_stream_close(stream: *mut nwep_stream, error: ::std::os::raw::c_int);
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_stream_get_id` gets the stream ID."]
    pub fn nwep_stream_get_id(stream: *const nwep_stream) -> i64;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_stream_get_user_data` gets user data for the stream."]
    pub fn nwep_stream_get_user_data(stream: *const nwep_stream) -> *mut ::std::os::raw::c_void;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_stream_set_user_data` sets user data for the stream."]
    pub fn nwep_stream_set_user_data(
        stream: *mut nwep_stream,
        user_data: *mut ::std::os::raw::c_void,
    );
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_stream_get_conn` gets the connection for a stream."]
    pub fn nwep_stream_get_conn(stream: *const nwep_stream) -> *mut nwep_conn;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_conn_notify` sends a NOTIFY to client, opening a new stream.\n |conn| must be a server connection. |pstream| receives the stream.\n\n This function returns 0 if it succeeds, or one of the following\n negative error codes:\n\n :macro:`NWEP_ERR_INTERNAL_INVALID_STATE`\n     Connection is not a server or not connected.\n :macro:`NWEP_ERR_INTERNAL_NOMEM`\n     Out of memory.\n :macro:`NWEP_ERR_NETWORK_QUIC`\n     Stream ID blocked."]
    pub fn nwep_conn_notify(
        conn: *mut nwep_conn,
        notify: *const nwep_notify,
        pstream: *mut *mut nwep_stream,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_notify_build` builds a NOTIFY message.\n\n This function returns 0 if it succeeds, or a negative error code."]
    pub fn nwep_notify_build(
        msg: *mut nwep_msg,
        headers: *mut nwep_header,
        max_headers: usize,
        event: *const ::std::os::raw::c_char,
        path: *const ::std::os::raw::c_char,
        notify_id: *const u8,
        body: *const u8,
        body_len: usize,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_notify_parse` parses a message into a notify structure.\n\n This function returns 0 if it succeeds, or one of the following\n negative error codes:\n\n :macro:`NWEP_ERR_PROTO_INVALID_MESSAGE`\n     Message is not a notify.\n :macro:`NWEP_ERR_PROTO_MISSING_HEADER`\n     Required header is missing."]
    pub fn nwep_notify_parse(
        notify: *mut nwep_notify,
        msg: *const nwep_msg,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_stream_is_server_initiated` returns nonzero if the stream was\n initiated by the server."]
    pub fn nwep_stream_is_server_initiated(stream: *const nwep_stream) -> ::std::os::raw::c_int;
}
#[doc = " @struct\n\n :type:`nwep_bls_keypair` holds a BLS12-381 keypair."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_bls_keypair {
    pub pubkey: [u8; 48usize],
    pub privkey: [u8; 32usize],
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
#[cfg(all(target_pointer_width = "64", not(target_os = "windows")))]
const _: () = {
    ["Size of nwep_bls_keypair"][::std::mem::size_of::<nwep_bls_keypair>() - 80usize];
    ["Alignment of nwep_bls_keypair"][::std::mem::align_of::<nwep_bls_keypair>() - 1usize];
    ["Offset of field: nwep_bls_keypair::pubkey"]
        [::std::mem::offset_of!(nwep_bls_keypair, pubkey) - 0usize];
    ["Offset of field: nwep_bls_keypair::privkey"]
        [::std::mem::offset_of!(nwep_bls_keypair, privkey) - 48usize];
};
#[doc = " @struct\n\n :type:`nwep_bls_pubkey` holds a BLS12-381 public key."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_bls_pubkey {
    pub data: [u8; 48usize],
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
#[cfg(all(target_pointer_width = "64", not(target_os = "windows")))]
const _: () = {
    ["Size of nwep_bls_pubkey"][::std::mem::size_of::<nwep_bls_pubkey>() - 48usize];
    ["Alignment of nwep_bls_pubkey"][::std::mem::align_of::<nwep_bls_pubkey>() - 1usize];
    ["Offset of field: nwep_bls_pubkey::data"]
        [::std::mem::offset_of!(nwep_bls_pubkey, data) - 0usize];
};
#[doc = " @struct\n\n :type:`nwep_bls_sig` holds a BLS12-381 signature."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_bls_sig {
    pub data: [u8; 96usize],
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
#[cfg(all(target_pointer_width = "64", not(target_os = "windows")))]
const _: () = {
    ["Size of nwep_bls_sig"][::std::mem::size_of::<nwep_bls_sig>() - 96usize];
    ["Alignment of nwep_bls_sig"][::std::mem::align_of::<nwep_bls_sig>() - 1usize];
    ["Offset of field: nwep_bls_sig::data"][::std::mem::offset_of!(nwep_bls_sig, data) - 0usize];
};
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_bls_keypair_generate` generates a new BLS12-381 keypair.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_bls_keypair_generate(kp: *mut nwep_bls_keypair) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_bls_keypair_from_seed` generates a BLS keypair deterministically.\n\n |ikm| is the input keying material (at least 32 bytes recommended).\n |ikm_len| is the length of ikm.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_bls_keypair_from_seed(
        kp: *mut nwep_bls_keypair,
        ikm: *const u8,
        ikm_len: usize,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_bls_pubkey_serialize` serializes a public key to bytes.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_bls_pubkey_serialize(
        out: *mut u8,
        pk: *const nwep_bls_pubkey,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_bls_pubkey_deserialize` deserializes a public key from bytes.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_bls_pubkey_deserialize(
        pk: *mut nwep_bls_pubkey,
        in_: *const u8,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_bls_sign` signs a message with a BLS private key.\n\n |sig| receives the signature.\n |kp| is the keypair.\n |msg| is the message to sign.\n |msg_len| is the message length.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_bls_sign(
        sig: *mut nwep_bls_sig,
        kp: *const nwep_bls_keypair,
        msg: *const u8,
        msg_len: usize,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_bls_verify` verifies a BLS signature.\n\n Returns 0 on success (valid), or a negative error code."]
    pub fn nwep_bls_verify(
        pk: *const nwep_bls_pubkey,
        sig: *const nwep_bls_sig,
        msg: *const u8,
        msg_len: usize,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_bls_aggregate_sigs` aggregates multiple BLS signatures.\n\n |out| receives the aggregated signature.\n |sigs| is an array of signatures.\n |n| is the number of signatures.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_bls_aggregate_sigs(
        out: *mut nwep_bls_sig,
        sigs: *const nwep_bls_sig,
        n: usize,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_bls_verify_aggregate` verifies an aggregated BLS signature.\n\n All signers must have signed the same message.\n\n |pks| is an array of public keys.\n |n| is the number of public keys.\n |sig| is the aggregated signature.\n |msg| is the message.\n |msg_len| is the message length.\n\n Returns 0 on success (valid), or a negative error code."]
    pub fn nwep_bls_verify_aggregate(
        pks: *const nwep_bls_pubkey,
        n: usize,
        sig: *const nwep_bls_sig,
        msg: *const u8,
        msg_len: usize,
    ) -> ::std::os::raw::c_int;
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_anchor_set {
    _unused: [u8; 0],
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_anchor_set_new` creates a new anchor set.\n\n |threshold| is the number of anchors required for a valid checkpoint.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_anchor_set_new(
        pset: *mut *mut nwep_anchor_set,
        threshold: usize,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_anchor_set_free` frees an anchor set."]
    pub fn nwep_anchor_set_free(set: *mut nwep_anchor_set);
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_anchor_set_add` adds an anchor public key to the set.\n\n |builtin| indicates if this is a built-in anchor (cannot be removed).\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_anchor_set_add(
        set: *mut nwep_anchor_set,
        pk: *const nwep_bls_pubkey,
        builtin: ::std::os::raw::c_int,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_anchor_set_remove` removes an anchor from the set.\n\n Built-in anchors cannot be removed.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_anchor_set_remove(
        set: *mut nwep_anchor_set,
        pk: *const nwep_bls_pubkey,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_anchor_set_size` returns the number of anchors in the set."]
    pub fn nwep_anchor_set_size(set: *const nwep_anchor_set) -> usize;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_anchor_set_get` retrieves an anchor by index.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_anchor_set_get(
        set: *const nwep_anchor_set,
        idx: usize,
        pk: *mut nwep_bls_pubkey,
        builtin: *mut ::std::os::raw::c_int,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_anchor_set_threshold` returns the threshold for the set."]
    pub fn nwep_anchor_set_threshold(set: *const nwep_anchor_set) -> usize;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_anchor_set_contains` checks if a public key is in the set.\n\n Returns 1 if found, 0 if not found."]
    pub fn nwep_anchor_set_contains(
        set: *const nwep_anchor_set,
        pk: *const nwep_bls_pubkey,
    ) -> ::std::os::raw::c_int;
}
#[doc = " @struct\n\n :type:`nwep_checkpoint` represents a signed epoch checkpoint."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_checkpoint {
    pub epoch: u64,
    pub timestamp: nwep_tstamp,
    pub merkle_root: nwep_merkle_hash,
    pub log_size: u64,
    pub signature: nwep_bls_sig,
    pub signers: [nwep_bls_pubkey; 32usize],
    pub num_signers: usize,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
#[cfg(all(target_pointer_width = "64", not(target_os = "windows")))]
const _: () = {
    ["Size of nwep_checkpoint"][::std::mem::size_of::<nwep_checkpoint>() - 1696usize];
    ["Alignment of nwep_checkpoint"][::std::mem::align_of::<nwep_checkpoint>() - 8usize];
    ["Offset of field: nwep_checkpoint::epoch"]
        [::std::mem::offset_of!(nwep_checkpoint, epoch) - 0usize];
    ["Offset of field: nwep_checkpoint::timestamp"]
        [::std::mem::offset_of!(nwep_checkpoint, timestamp) - 8usize];
    ["Offset of field: nwep_checkpoint::merkle_root"]
        [::std::mem::offset_of!(nwep_checkpoint, merkle_root) - 16usize];
    ["Offset of field: nwep_checkpoint::log_size"]
        [::std::mem::offset_of!(nwep_checkpoint, log_size) - 48usize];
    ["Offset of field: nwep_checkpoint::signature"]
        [::std::mem::offset_of!(nwep_checkpoint, signature) - 56usize];
    ["Offset of field: nwep_checkpoint::signers"]
        [::std::mem::offset_of!(nwep_checkpoint, signers) - 152usize];
    ["Offset of field: nwep_checkpoint::num_signers"]
        [::std::mem::offset_of!(nwep_checkpoint, num_signers) - 1688usize];
};
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_checkpoint_new` creates a new checkpoint proposal.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_checkpoint_new(
        cp: *mut nwep_checkpoint,
        epoch: u64,
        timestamp: nwep_tstamp,
        merkle_root: *const nwep_merkle_hash,
        log_size: u64,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_checkpoint_sign` signs a checkpoint with an anchor's key.\n\n Adds the signature to the checkpoint's aggregated signature.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_checkpoint_sign(
        cp: *mut nwep_checkpoint,
        anchor_kp: *const nwep_bls_keypair,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_checkpoint_verify` verifies a checkpoint's signatures.\n\n |anchor_set| is the trusted anchor set.\n\n Returns 0 if valid (threshold reached), or a negative error code."]
    pub fn nwep_checkpoint_verify(
        cp: *const nwep_checkpoint,
        anchor_set: *const nwep_anchor_set,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_checkpoint_encode` serializes a checkpoint.\n\n Returns the number of bytes written, or a negative error code."]
    pub fn nwep_checkpoint_encode(
        buf: *mut u8,
        buflen: usize,
        cp: *const nwep_checkpoint,
    ) -> nwep_ssize;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_checkpoint_decode` deserializes a checkpoint.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_checkpoint_decode(
        cp: *mut nwep_checkpoint,
        data: *const u8,
        datalen: usize,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_checkpoint_message` computes the message to be signed.\n\n This is the canonical encoding: epoch || timestamp || merkle_root || log_size\n\n Returns the number of bytes written (always 56), or a negative error code."]
    pub fn nwep_checkpoint_message(
        buf: *mut u8,
        buflen: usize,
        cp: *const nwep_checkpoint,
    ) -> nwep_ssize;
}
#[doc = " @callback\n\n `nwep_trust_anchor_load_cb` loads anchors from persistent storage.\n Returns number of anchors loaded, or negative error code."]
pub type nwep_trust_anchor_load_cb = ::std::option::Option<
    unsafe extern "C" fn(
        user_data: *mut ::std::os::raw::c_void,
        anchors: *mut nwep_bls_pubkey,
        max_anchors: usize,
    ) -> ::std::os::raw::c_int,
>;
#[doc = " @callback\n\n `nwep_trust_anchor_save_cb` saves anchors to persistent storage.\n Returns 0 on success, or negative error code."]
pub type nwep_trust_anchor_save_cb = ::std::option::Option<
    unsafe extern "C" fn(
        user_data: *mut ::std::os::raw::c_void,
        anchors: *const nwep_bls_pubkey,
        count: usize,
    ) -> ::std::os::raw::c_int,
>;
#[doc = " @callback\n\n `nwep_trust_checkpoint_load_cb` loads checkpoints from persistent storage.\n Returns number of checkpoints loaded, or negative error code."]
pub type nwep_trust_checkpoint_load_cb = ::std::option::Option<
    unsafe extern "C" fn(
        user_data: *mut ::std::os::raw::c_void,
        checkpoints: *mut nwep_checkpoint,
        max_checkpoints: usize,
    ) -> ::std::os::raw::c_int,
>;
#[doc = " @callback\n\n `nwep_trust_checkpoint_save_cb` saves a checkpoint to persistent storage.\n Returns 0 on success, or negative error code."]
pub type nwep_trust_checkpoint_save_cb = ::std::option::Option<
    unsafe extern "C" fn(
        user_data: *mut ::std::os::raw::c_void,
        cp: *const nwep_checkpoint,
    ) -> ::std::os::raw::c_int,
>;
#[doc = " @struct\n\n :type:`nwep_trust_storage` holds optional persistence callbacks."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_trust_storage {
    pub anchor_load: nwep_trust_anchor_load_cb,
    pub anchor_save: nwep_trust_anchor_save_cb,
    pub checkpoint_load: nwep_trust_checkpoint_load_cb,
    pub checkpoint_save: nwep_trust_checkpoint_save_cb,
    pub user_data: *mut ::std::os::raw::c_void,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
#[cfg(all(target_pointer_width = "64", not(target_os = "windows")))]
const _: () = {
    ["Size of nwep_trust_storage"][::std::mem::size_of::<nwep_trust_storage>() - 40usize];
    ["Alignment of nwep_trust_storage"][::std::mem::align_of::<nwep_trust_storage>() - 8usize];
    ["Offset of field: nwep_trust_storage::anchor_load"]
        [::std::mem::offset_of!(nwep_trust_storage, anchor_load) - 0usize];
    ["Offset of field: nwep_trust_storage::anchor_save"]
        [::std::mem::offset_of!(nwep_trust_storage, anchor_save) - 8usize];
    ["Offset of field: nwep_trust_storage::checkpoint_load"]
        [::std::mem::offset_of!(nwep_trust_storage, checkpoint_load) - 16usize];
    ["Offset of field: nwep_trust_storage::checkpoint_save"]
        [::std::mem::offset_of!(nwep_trust_storage, checkpoint_save) - 24usize];
    ["Offset of field: nwep_trust_storage::user_data"]
        [::std::mem::offset_of!(nwep_trust_storage, user_data) - 32usize];
};
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_trust_store {
    _unused: [u8; 0],
}
#[doc = " @struct\n\n :type:`nwep_trust_settings` configures trust store behavior."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_trust_settings {
    #[doc = " :member:`staleness_warning_ns` is the warning threshold in nanoseconds.\n Default: NWEP_STALENESS_WARNING_NS (1 hour)."]
    pub staleness_warning_ns: nwep_duration,
    #[doc = " :member:`staleness_reject_ns` is the rejection threshold in nanoseconds.\n Default: NWEP_STALENESS_REJECT_NS (24 hours)."]
    pub staleness_reject_ns: nwep_duration,
    #[doc = " :member:`identity_cache_ttl` is the identity cache TTL in nanoseconds.\n Default: NWEP_IDENTITY_CACHE_TTL (1 hour)."]
    pub identity_cache_ttl: nwep_duration,
    #[doc = " :member:`anchor_threshold` is the minimum anchors for valid checkpoint.\n Default: NWEP_DEFAULT_ANCHOR_THRESHOLD."]
    pub anchor_threshold: usize,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
#[cfg(all(target_pointer_width = "64", not(target_os = "windows")))]
const _: () = {
    ["Size of nwep_trust_settings"][::std::mem::size_of::<nwep_trust_settings>() - 32usize];
    ["Alignment of nwep_trust_settings"][::std::mem::align_of::<nwep_trust_settings>() - 8usize];
    ["Offset of field: nwep_trust_settings::staleness_warning_ns"]
        [::std::mem::offset_of!(nwep_trust_settings, staleness_warning_ns) - 0usize];
    ["Offset of field: nwep_trust_settings::staleness_reject_ns"]
        [::std::mem::offset_of!(nwep_trust_settings, staleness_reject_ns) - 8usize];
    ["Offset of field: nwep_trust_settings::identity_cache_ttl"]
        [::std::mem::offset_of!(nwep_trust_settings, identity_cache_ttl) - 16usize];
    ["Offset of field: nwep_trust_settings::anchor_threshold"]
        [::std::mem::offset_of!(nwep_trust_settings, anchor_threshold) - 24usize];
};
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_trust_settings_default` initializes settings to defaults."]
    pub fn nwep_trust_settings_default(settings: *mut nwep_trust_settings);
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_trust_store_new` creates a new trust store.\n\n |settings| configures behavior (NULL for defaults).\n |storage| provides optional persistence (NULL for in-memory only).\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_trust_store_new(
        pstore: *mut *mut nwep_trust_store,
        settings: *const nwep_trust_settings,
        storage: *const nwep_trust_storage,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_trust_store_free` frees a trust store."]
    pub fn nwep_trust_store_free(store: *mut nwep_trust_store);
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_trust_store_add_anchor` adds a trusted anchor.\n\n |builtin| indicates if this is a built-in anchor (cannot be removed).\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_trust_store_add_anchor(
        store: *mut nwep_trust_store,
        pk: *const nwep_bls_pubkey,
        builtin: ::std::os::raw::c_int,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_trust_store_remove_anchor` removes a non-builtin anchor.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_trust_store_remove_anchor(
        store: *mut nwep_trust_store,
        pk: *const nwep_bls_pubkey,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_trust_store_get_anchors` retrieves the anchor set.\n\n The returned anchor set is owned by the trust store; do not free it."]
    pub fn nwep_trust_store_get_anchors(store: *const nwep_trust_store) -> *const nwep_anchor_set;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_trust_store_add_checkpoint` adds a verified checkpoint.\n\n The checkpoint is verified against the anchor set before storing.\n\n Returns 0 on success, or one of the following negative error codes:\n\n :macro:`NWEP_ERR_TRUST_QUORUM_NOT_REACHED`\n     Checkpoint does not have enough valid signatures.\n :macro:`NWEP_ERR_CRYPTO_SIGN_FAILED`\n     Signature verification failed."]
    pub fn nwep_trust_store_add_checkpoint(
        store: *mut nwep_trust_store,
        cp: *const nwep_checkpoint,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_trust_store_get_latest_checkpoint` retrieves the most recent checkpoint.\n\n Returns 0 on success, or NWEP_ERR_TRUST_ENTRY_NOT_FOUND if no checkpoints."]
    pub fn nwep_trust_store_get_latest_checkpoint(
        store: *const nwep_trust_store,
        cp: *mut nwep_checkpoint,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_trust_store_get_checkpoint` retrieves a checkpoint by epoch.\n\n Returns 0 on success, or NWEP_ERR_TRUST_ENTRY_NOT_FOUND if not found."]
    pub fn nwep_trust_store_get_checkpoint(
        store: *const nwep_trust_store,
        epoch: u64,
        cp: *mut nwep_checkpoint,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_trust_store_checkpoint_count` returns number of stored checkpoints."]
    pub fn nwep_trust_store_checkpoint_count(store: *const nwep_trust_store) -> usize;
}
pub const nwep_staleness_NWEP_STALENESS_FRESH: nwep_staleness = 0;
pub const nwep_staleness_NWEP_STALENESS_WARNING: nwep_staleness = 1;
pub const nwep_staleness_NWEP_STALENESS_REJECT: nwep_staleness = 2;
#[doc = " @enum\n\n :type:`nwep_staleness` indicates checkpoint freshness status."]
pub type nwep_staleness = ::std::os::raw::c_uint;
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_trust_store_check_staleness` checks checkpoint freshness.\n\n |now| is the current timestamp.\n\n Returns staleness status."]
    pub fn nwep_trust_store_check_staleness(
        store: *const nwep_trust_store,
        now: nwep_tstamp,
    ) -> nwep_staleness;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_trust_store_get_staleness_age` returns age since last checkpoint.\n\n Returns 0 if no checkpoints stored."]
    pub fn nwep_trust_store_get_staleness_age(
        store: *const nwep_trust_store,
        now: nwep_tstamp,
    ) -> nwep_duration;
}
#[doc = " @struct\n\n :type:`nwep_verified_identity` holds a verified identity with proof."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_verified_identity {
    pub nodeid: nwep_nodeid,
    pub pubkey: [u8; 32usize],
    pub log_index: u64,
    pub checkpoint_epoch: u64,
    pub verified_at: nwep_tstamp,
    pub revoked: ::std::os::raw::c_int,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
#[cfg(all(target_pointer_width = "64", not(target_os = "windows")))]
const _: () = {
    ["Size of nwep_verified_identity"][::std::mem::size_of::<nwep_verified_identity>() - 96usize];
    ["Alignment of nwep_verified_identity"]
        [::std::mem::align_of::<nwep_verified_identity>() - 8usize];
    ["Offset of field: nwep_verified_identity::nodeid"]
        [::std::mem::offset_of!(nwep_verified_identity, nodeid) - 0usize];
    ["Offset of field: nwep_verified_identity::pubkey"]
        [::std::mem::offset_of!(nwep_verified_identity, pubkey) - 32usize];
    ["Offset of field: nwep_verified_identity::log_index"]
        [::std::mem::offset_of!(nwep_verified_identity, log_index) - 64usize];
    ["Offset of field: nwep_verified_identity::checkpoint_epoch"]
        [::std::mem::offset_of!(nwep_verified_identity, checkpoint_epoch) - 72usize];
    ["Offset of field: nwep_verified_identity::verified_at"]
        [::std::mem::offset_of!(nwep_verified_identity, verified_at) - 80usize];
    ["Offset of field: nwep_verified_identity::revoked"]
        [::std::mem::offset_of!(nwep_verified_identity, revoked) - 88usize];
};
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_trust_store_verify_identity` verifies an identity against a checkpoint.\n\n |entry| is the log entry claiming the identity.\n |proof| is the inclusion proof for the entry.\n |checkpoint| is the checkpoint to verify against (NULL for latest).\n\n Returns 0 if valid, or one of the following negative error codes:\n\n :macro:`NWEP_ERR_TRUST_INVALID_PROOF`\n     Proof does not verify against checkpoint merkle root.\n :macro:`NWEP_ERR_TRUST_ENTRY_NOT_FOUND`\n     No checkpoints available.\n :macro:`NWEP_ERR_TRUST_CHECKPOINT_STALE`\n     Checkpoint is too old."]
    pub fn nwep_trust_store_verify_identity(
        store: *mut nwep_trust_store,
        entry: *const nwep_merkle_entry,
        proof: *const nwep_merkle_proof,
        checkpoint: *const nwep_checkpoint,
        now: nwep_tstamp,
        result: *mut nwep_verified_identity,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_trust_store_cache_identity` caches a verified identity.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_trust_store_cache_identity(
        store: *mut nwep_trust_store,
        identity: *const nwep_verified_identity,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_trust_store_lookup_identity` looks up a cached identity by NodeID.\n\n Returns 0 if found and valid, or NWEP_ERR_TRUST_NODE_NOT_FOUND."]
    pub fn nwep_trust_store_lookup_identity(
        store: *const nwep_trust_store,
        nodeid: *const nwep_nodeid,
        now: nwep_tstamp,
        out: *mut nwep_verified_identity,
    ) -> ::std::os::raw::c_int;
}
#[doc = " @struct\n\n :type:`nwep_equivocation` describes a detected equivocation."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_equivocation {
    pub anchor: nwep_bls_pubkey,
    pub epoch: u64,
    pub root1: nwep_merkle_hash,
    pub root2: nwep_merkle_hash,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
#[cfg(all(target_pointer_width = "64", not(target_os = "windows")))]
const _: () = {
    ["Size of nwep_equivocation"][::std::mem::size_of::<nwep_equivocation>() - 120usize];
    ["Alignment of nwep_equivocation"][::std::mem::align_of::<nwep_equivocation>() - 8usize];
    ["Offset of field: nwep_equivocation::anchor"]
        [::std::mem::offset_of!(nwep_equivocation, anchor) - 0usize];
    ["Offset of field: nwep_equivocation::epoch"]
        [::std::mem::offset_of!(nwep_equivocation, epoch) - 48usize];
    ["Offset of field: nwep_equivocation::root1"]
        [::std::mem::offset_of!(nwep_equivocation, root1) - 56usize];
    ["Offset of field: nwep_equivocation::root2"]
        [::std::mem::offset_of!(nwep_equivocation, root2) - 88usize];
};
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_trust_store_check_equivocation` checks for conflicting checkpoints.\n\n Compares |cp| against stored checkpoints for the same epoch.\n\n Returns 0 if no equivocation, or NWEP_ERR_TRUST_EQUIVOCATION if detected.\n If detected, |out| receives details (if not NULL)."]
    pub fn nwep_trust_store_check_equivocation(
        store: *mut nwep_trust_store,
        cp: *const nwep_checkpoint,
        out: *mut nwep_equivocation,
    ) -> ::std::os::raw::c_int;
}
#[doc = " :enum:`NWEP_ROLE_REGULAR` is a regular node (client connections, forwarding)."]
pub const nwep_server_role_NWEP_ROLE_REGULAR: nwep_server_role = 0;
#[doc = " :enum:`NWEP_ROLE_LOG_SERVER` is a Merkle log server."]
pub const nwep_server_role_NWEP_ROLE_LOG_SERVER: nwep_server_role = 1;
#[doc = " :enum:`NWEP_ROLE_ANCHOR` is an anchor server (checkpoint signing)."]
pub const nwep_server_role_NWEP_ROLE_ANCHOR: nwep_server_role = 2;
#[doc = " @enum\n\n :type:`nwep_server_role` defines the server role types."]
pub type nwep_server_role = ::std::os::raw::c_uint;
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_role_from_str` converts a role string to enum.\n\n Returns the role enum, or NWEP_ROLE_REGULAR if unknown."]
    pub fn nwep_role_from_str(role_str: *const ::std::os::raw::c_char) -> nwep_server_role;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_role_to_str` converts a role enum to string.\n\n Returns the role string."]
    pub fn nwep_role_to_str(role: nwep_server_role) -> *const ::std::os::raw::c_char;
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_log_server {
    _unused: [u8; 0],
}
#[doc = " @callback\n\n `nwep_log_authorize_cb` checks if a client is authorized to write entries.\n\n |nodeid| is the client's NodeID.\n |entry| is the entry they want to write.\n\n Returns 0 if authorized, or NWEP_ERR_PROTO_UNAUTHORIZED if not."]
pub type nwep_log_authorize_cb = ::std::option::Option<
    unsafe extern "C" fn(
        user_data: *mut ::std::os::raw::c_void,
        nodeid: *const nwep_nodeid,
        entry: *const nwep_merkle_entry,
    ) -> ::std::os::raw::c_int,
>;
#[doc = " @struct\n\n :type:`nwep_log_server_settings` configures log server behavior."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_log_server_settings {
    #[doc = " :member:`authorize` is called before accepting write requests.\n If NULL, only read operations are allowed."]
    pub authorize: nwep_log_authorize_cb,
    #[doc = " :member:`user_data` is passed to callbacks."]
    pub user_data: *mut ::std::os::raw::c_void,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
#[cfg(all(target_pointer_width = "64", not(target_os = "windows")))]
const _: () = {
    ["Size of nwep_log_server_settings"]
        [::std::mem::size_of::<nwep_log_server_settings>() - 16usize];
    ["Alignment of nwep_log_server_settings"]
        [::std::mem::align_of::<nwep_log_server_settings>() - 8usize];
    ["Offset of field: nwep_log_server_settings::authorize"]
        [::std::mem::offset_of!(nwep_log_server_settings, authorize) - 0usize];
    ["Offset of field: nwep_log_server_settings::user_data"]
        [::std::mem::offset_of!(nwep_log_server_settings, user_data) - 8usize];
};
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_log_server_new` creates a new log server.\n\n |log| is the Merkle log to serve.\n |settings| configures server behavior (NULL for defaults).\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_log_server_new(
        pserver: *mut *mut nwep_log_server,
        log: *mut nwep_merkle_log,
        settings: *const nwep_log_server_settings,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_log_server_free` frees a log server."]
    pub fn nwep_log_server_free(server: *mut nwep_log_server);
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_log_server_handle_request` handles a log server request.\n\n Handles paths:\n - READ /log/entry/{index} - returns entry at index\n - READ /log/proof/{index} - returns inclusion proof\n - READ /log/size - returns current log size\n - WRITE /log/entry - appends entry (if authorized)\n\n |stream| is the stream to respond on.\n |request| is the incoming request.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_log_server_handle_request(
        server: *mut nwep_log_server,
        stream: *mut nwep_stream,
        request: *const nwep_request,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_log_server_get_log` returns the underlying Merkle log."]
    pub fn nwep_log_server_get_log(server: *mut nwep_log_server) -> *mut nwep_merkle_log;
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_anchor_server {
    _unused: [u8; 0],
}
#[doc = " @callback\n\n `nwep_anchor_proposal_cb` is called when a checkpoint proposal is received.\n\n |cp| is the proposed checkpoint.\n Returns 0 to sign and accept, or a negative error code to reject."]
pub type nwep_anchor_proposal_cb = ::std::option::Option<
    unsafe extern "C" fn(
        user_data: *mut ::std::os::raw::c_void,
        cp: *const nwep_checkpoint,
    ) -> ::std::os::raw::c_int,
>;
#[doc = " @struct\n\n :type:`nwep_anchor_server_settings` configures anchor server behavior."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_anchor_server_settings {
    #[doc = " :member:`on_proposal` is called when receiving checkpoint proposals.\n If NULL, all valid proposals are signed."]
    pub on_proposal: nwep_anchor_proposal_cb,
    #[doc = " :member:`user_data` is passed to callbacks."]
    pub user_data: *mut ::std::os::raw::c_void,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
#[cfg(all(target_pointer_width = "64", not(target_os = "windows")))]
const _: () = {
    ["Size of nwep_anchor_server_settings"]
        [::std::mem::size_of::<nwep_anchor_server_settings>() - 16usize];
    ["Alignment of nwep_anchor_server_settings"]
        [::std::mem::align_of::<nwep_anchor_server_settings>() - 8usize];
    ["Offset of field: nwep_anchor_server_settings::on_proposal"]
        [::std::mem::offset_of!(nwep_anchor_server_settings, on_proposal) - 0usize];
    ["Offset of field: nwep_anchor_server_settings::user_data"]
        [::std::mem::offset_of!(nwep_anchor_server_settings, user_data) - 8usize];
};
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_anchor_server_new` creates a new anchor server.\n\n |keypair| is the BLS keypair for signing checkpoints.\n |anchors| is the trusted anchor set.\n |settings| configures server behavior (NULL for defaults).\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_anchor_server_new(
        pserver: *mut *mut nwep_anchor_server,
        keypair: *const nwep_bls_keypair,
        anchors: *mut nwep_anchor_set,
        settings: *const nwep_anchor_server_settings,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_anchor_server_free` frees an anchor server."]
    pub fn nwep_anchor_server_free(server: *mut nwep_anchor_server);
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_anchor_server_handle_request` handles an anchor server request.\n\n Handles paths:\n - READ /checkpoint/latest - returns latest finalized checkpoint\n - READ /checkpoint/{epoch} - returns checkpoint for specific epoch\n - WRITE /checkpoint/propose - receives checkpoint proposal\n - WRITE /checkpoint/signature - receives signature for proposal\n\n |stream| is the stream to respond on.\n |request| is the incoming request.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_anchor_server_handle_request(
        server: *mut nwep_anchor_server,
        stream: *mut nwep_stream,
        request: *const nwep_request,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_anchor_server_add_checkpoint` adds a finalized checkpoint.\n\n Call this after collecting enough signatures for a checkpoint."]
    pub fn nwep_anchor_server_add_checkpoint(
        server: *mut nwep_anchor_server,
        cp: *const nwep_checkpoint,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_anchor_server_get_latest` gets the latest finalized checkpoint.\n\n Returns 0 on success, or NWEP_ERR_TRUST_ENTRY_NOT_FOUND if none."]
    pub fn nwep_anchor_server_get_latest(
        server: *const nwep_anchor_server,
        cp: *mut nwep_checkpoint,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_anchor_server_get_checkpoint` gets a checkpoint by epoch.\n\n Returns 0 on success, or NWEP_ERR_TRUST_ENTRY_NOT_FOUND if not found."]
    pub fn nwep_anchor_server_get_checkpoint(
        server: *const nwep_anchor_server,
        epoch: u64,
        cp: *mut nwep_checkpoint,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_anchor_server_create_proposal` creates a checkpoint proposal.\n\n |log| is the Merkle log to checkpoint.\n |epoch| is the epoch number.\n |timestamp| is the checkpoint timestamp.\n |cp| receives the unsigned checkpoint proposal.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_anchor_server_create_proposal(
        server: *mut nwep_anchor_server,
        log: *mut nwep_merkle_log,
        epoch: u64,
        timestamp: nwep_tstamp,
        cp: *mut nwep_checkpoint,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_anchor_server_sign_proposal` signs a checkpoint proposal.\n\n |cp| is the checkpoint to sign (modified in place with signature).\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_anchor_server_sign_proposal(
        server: *mut nwep_anchor_server,
        cp: *mut nwep_checkpoint,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_conn_get_peer_role` gets the peer's announced server role.\n\n Returns the role enum, or NWEP_ROLE_REGULAR if not specified."]
    pub fn nwep_conn_get_peer_role(conn: *const nwep_conn) -> nwep_server_role;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_conn_set_required_role` sets the required role for the connection.\n\n Call before connecting. The connection will fail if the server\n doesn't have the required role.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_conn_set_required_role(
        conn: *mut nwep_conn,
        role: nwep_server_role,
    ) -> ::std::os::raw::c_int;
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_identity_cache {
    _unused: [u8; 0],
}
#[doc = " @struct\n\n :type:`nwep_cached_identity` represents a cached verified identity."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_cached_identity {
    pub nodeid: nwep_nodeid,
    pub pubkey: [u8; 32usize],
    pub log_index: u64,
    pub verified_at: nwep_tstamp,
    pub expires_at: nwep_tstamp,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
#[cfg(all(target_pointer_width = "64", not(target_os = "windows")))]
const _: () = {
    ["Size of nwep_cached_identity"][::std::mem::size_of::<nwep_cached_identity>() - 88usize];
    ["Alignment of nwep_cached_identity"][::std::mem::align_of::<nwep_cached_identity>() - 8usize];
    ["Offset of field: nwep_cached_identity::nodeid"]
        [::std::mem::offset_of!(nwep_cached_identity, nodeid) - 0usize];
    ["Offset of field: nwep_cached_identity::pubkey"]
        [::std::mem::offset_of!(nwep_cached_identity, pubkey) - 32usize];
    ["Offset of field: nwep_cached_identity::log_index"]
        [::std::mem::offset_of!(nwep_cached_identity, log_index) - 64usize];
    ["Offset of field: nwep_cached_identity::verified_at"]
        [::std::mem::offset_of!(nwep_cached_identity, verified_at) - 72usize];
    ["Offset of field: nwep_cached_identity::expires_at"]
        [::std::mem::offset_of!(nwep_cached_identity, expires_at) - 80usize];
};
#[doc = " @struct\n\n :type:`nwep_identity_cache_settings` configures cache behavior."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_identity_cache_settings {
    #[doc = " :member:`capacity` is the maximum number of entries.\n Default: NWEP_CACHE_DEFAULT_CAPACITY (10000)"]
    pub capacity: usize,
    #[doc = " :member:`ttl_ns` is the TTL in nanoseconds.\n Default: NWEP_CACHE_DEFAULT_TTL_NS (1 hour)"]
    pub ttl_ns: nwep_tstamp,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
#[cfg(all(target_pointer_width = "64", not(target_os = "windows")))]
const _: () = {
    ["Size of nwep_identity_cache_settings"]
        [::std::mem::size_of::<nwep_identity_cache_settings>() - 16usize];
    ["Alignment of nwep_identity_cache_settings"]
        [::std::mem::align_of::<nwep_identity_cache_settings>() - 8usize];
    ["Offset of field: nwep_identity_cache_settings::capacity"]
        [::std::mem::offset_of!(nwep_identity_cache_settings, capacity) - 0usize];
    ["Offset of field: nwep_identity_cache_settings::ttl_ns"]
        [::std::mem::offset_of!(nwep_identity_cache_settings, ttl_ns) - 8usize];
};
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_identity_cache_settings_default` initializes settings to defaults."]
    pub fn nwep_identity_cache_settings_default(settings: *mut nwep_identity_cache_settings);
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_identity_cache_new` creates a new identity cache.\n\n |settings| configures cache behavior (NULL for defaults).\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_identity_cache_new(
        pcache: *mut *mut nwep_identity_cache,
        settings: *const nwep_identity_cache_settings,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_identity_cache_free` frees an identity cache."]
    pub fn nwep_identity_cache_free(cache: *mut nwep_identity_cache);
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_identity_cache_lookup` looks up an identity by NodeID.\n\n |now| is the current timestamp for TTL checking.\n |identity| receives the cached identity if found and not expired.\n\n Returns 0 on success, NWEP_ERR_TRUST_ENTRY_NOT_FOUND if not found or expired."]
    pub fn nwep_identity_cache_lookup(
        cache: *mut nwep_identity_cache,
        nodeid: *const nwep_nodeid,
        now: nwep_tstamp,
        identity: *mut nwep_cached_identity,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_identity_cache_store` stores a verified identity.\n\n |now| is the current timestamp for setting verified_at and expires_at.\n |nodeid| is the NodeID to cache.\n |pubkey| is the verified public key.\n |log_index| is the log index where the identity was verified.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_identity_cache_store(
        cache: *mut nwep_identity_cache,
        nodeid: *const nwep_nodeid,
        pubkey: *const u8,
        log_index: u64,
        now: nwep_tstamp,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_identity_cache_invalidate` invalidates an entry by NodeID.\n\n Returns 0 on success, NWEP_ERR_TRUST_ENTRY_NOT_FOUND if not found."]
    pub fn nwep_identity_cache_invalidate(
        cache: *mut nwep_identity_cache,
        nodeid: *const nwep_nodeid,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_identity_cache_clear` clears all entries from the cache."]
    pub fn nwep_identity_cache_clear(cache: *mut nwep_identity_cache);
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_identity_cache_size` returns the number of entries in the cache."]
    pub fn nwep_identity_cache_size(cache: *const nwep_identity_cache) -> usize;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_identity_cache_capacity` returns the cache capacity."]
    pub fn nwep_identity_cache_capacity(cache: *const nwep_identity_cache) -> usize;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_identity_cache_on_rotation` handles key rotation notification.\n\n Invalidates the cached identity for |nodeid| since the key has changed.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_identity_cache_on_rotation(
        cache: *mut nwep_identity_cache,
        nodeid: *const nwep_nodeid,
        new_pubkey: *const u8,
        new_log_index: u64,
        now: nwep_tstamp,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_identity_cache_on_revocation` handles key revocation notification.\n\n Invalidates the cached identity for |nodeid| since the key has been revoked.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_identity_cache_on_revocation(
        cache: *mut nwep_identity_cache,
        nodeid: *const nwep_nodeid,
    ) -> ::std::os::raw::c_int;
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_log_server_pool {
    _unused: [u8; 0],
}
#[doc = " :enum:`NWEP_POOL_ROUND_ROBIN` selects servers in round-robin order."]
pub const nwep_pool_strategy_NWEP_POOL_ROUND_ROBIN: nwep_pool_strategy = 0;
#[doc = " :enum:`NWEP_POOL_RANDOM` selects servers randomly."]
pub const nwep_pool_strategy_NWEP_POOL_RANDOM: nwep_pool_strategy = 1;
#[doc = " @enum\n\n :type:`nwep_pool_strategy` defines the load balancing strategy."]
pub type nwep_pool_strategy = ::std::os::raw::c_uint;
#[doc = " :enum:`NWEP_SERVER_HEALTHY` means the server is responding normally."]
pub const nwep_server_health_NWEP_SERVER_HEALTHY: nwep_server_health = 0;
#[doc = " :enum:`NWEP_SERVER_UNHEALTHY` means the server has failed health checks."]
pub const nwep_server_health_NWEP_SERVER_UNHEALTHY: nwep_server_health = 1;
#[doc = " @enum\n\n :type:`nwep_server_health` indicates server health status."]
pub type nwep_server_health = ::std::os::raw::c_uint;
#[doc = " @struct\n\n :type:`nwep_pool_server` represents a server in the pool."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_pool_server {
    pub url: [::std::os::raw::c_char; 256usize],
    pub health: nwep_server_health,
    pub consecutive_failures: ::std::os::raw::c_int,
    pub last_success: nwep_tstamp,
    pub last_failure: nwep_tstamp,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
#[cfg(all(target_pointer_width = "64", not(target_os = "windows")))]
const _: () = {
    ["Size of nwep_pool_server"][::std::mem::size_of::<nwep_pool_server>() - 280usize];
    ["Alignment of nwep_pool_server"][::std::mem::align_of::<nwep_pool_server>() - 8usize];
    ["Offset of field: nwep_pool_server::url"]
        [::std::mem::offset_of!(nwep_pool_server, url) - 0usize];
    ["Offset of field: nwep_pool_server::health"]
        [::std::mem::offset_of!(nwep_pool_server, health) - 256usize];
    ["Offset of field: nwep_pool_server::consecutive_failures"]
        [::std::mem::offset_of!(nwep_pool_server, consecutive_failures) - 260usize];
    ["Offset of field: nwep_pool_server::last_success"]
        [::std::mem::offset_of!(nwep_pool_server, last_success) - 264usize];
    ["Offset of field: nwep_pool_server::last_failure"]
        [::std::mem::offset_of!(nwep_pool_server, last_failure) - 272usize];
};
#[doc = " @struct\n\n :type:`nwep_log_server_pool_settings` configures pool behavior."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_log_server_pool_settings {
    #[doc = " :member:`strategy` is the load balancing strategy."]
    pub strategy: nwep_pool_strategy,
    #[doc = " :member:`max_failures` is failures before marking unhealthy.\n Default: NWEP_POOL_HEALTH_CHECK_FAILURES (3)"]
    pub max_failures: ::std::os::raw::c_int,
    #[doc = " :member:`rand` is the random callback for RANDOM strategy."]
    pub rand: nwep_rand,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
#[cfg(all(target_pointer_width = "64", not(target_os = "windows")))]
const _: () = {
    ["Size of nwep_log_server_pool_settings"]
        [::std::mem::size_of::<nwep_log_server_pool_settings>() - 16usize];
    ["Alignment of nwep_log_server_pool_settings"]
        [::std::mem::align_of::<nwep_log_server_pool_settings>() - 8usize];
    ["Offset of field: nwep_log_server_pool_settings::strategy"]
        [::std::mem::offset_of!(nwep_log_server_pool_settings, strategy) - 0usize];
    ["Offset of field: nwep_log_server_pool_settings::max_failures"]
        [::std::mem::offset_of!(nwep_log_server_pool_settings, max_failures) - 4usize];
    ["Offset of field: nwep_log_server_pool_settings::rand"]
        [::std::mem::offset_of!(nwep_log_server_pool_settings, rand) - 8usize];
};
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_log_server_pool_settings_default` initializes settings to defaults."]
    pub fn nwep_log_server_pool_settings_default(settings: *mut nwep_log_server_pool_settings);
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_log_server_pool_new` creates a new log server pool.\n\n |settings| configures pool behavior (NULL for defaults).\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_log_server_pool_new(
        ppool: *mut *mut nwep_log_server_pool,
        settings: *const nwep_log_server_pool_settings,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_log_server_pool_free` frees a log server pool."]
    pub fn nwep_log_server_pool_free(pool: *mut nwep_log_server_pool);
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_log_server_pool_add` adds a server to the pool.\n\n |url| is the server URL (e.g., \"web://...\").\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_log_server_pool_add(
        pool: *mut nwep_log_server_pool,
        url: *const ::std::os::raw::c_char,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_log_server_pool_remove` removes a server from the pool.\n\n Returns 0 on success, NWEP_ERR_TRUST_ENTRY_NOT_FOUND if not found."]
    pub fn nwep_log_server_pool_remove(
        pool: *mut nwep_log_server_pool,
        url: *const ::std::os::raw::c_char,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_log_server_pool_select` selects a healthy server from the pool.\n\n |server| receives the selected server info.\n\n Returns 0 on success, NWEP_ERR_NETWORK_NO_SERVERS if no healthy servers."]
    pub fn nwep_log_server_pool_select(
        pool: *mut nwep_log_server_pool,
        server: *mut nwep_pool_server,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_log_server_pool_mark_success` marks a server as successful.\n\n Resets failure count and updates last_success timestamp."]
    pub fn nwep_log_server_pool_mark_success(
        pool: *mut nwep_log_server_pool,
        url: *const ::std::os::raw::c_char,
        now: nwep_tstamp,
    );
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_log_server_pool_mark_failure` marks a server as failed.\n\n Increments failure count and may mark server unhealthy."]
    pub fn nwep_log_server_pool_mark_failure(
        pool: *mut nwep_log_server_pool,
        url: *const ::std::os::raw::c_char,
        now: nwep_tstamp,
    );
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_log_server_pool_size` returns the number of servers in the pool."]
    pub fn nwep_log_server_pool_size(pool: *const nwep_log_server_pool) -> usize;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_log_server_pool_healthy_count` returns the number of healthy servers."]
    pub fn nwep_log_server_pool_healthy_count(pool: *const nwep_log_server_pool) -> usize;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_log_server_pool_get` gets a server by index.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_log_server_pool_get(
        pool: *const nwep_log_server_pool,
        index: usize,
        server: *mut nwep_pool_server,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_log_server_pool_reset_health` resets all servers to healthy."]
    pub fn nwep_log_server_pool_reset_health(pool: *mut nwep_log_server_pool);
}
#[doc = " @struct\n\n :type:`nwep_cache_stats` holds cache statistics."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_cache_stats {
    pub hits: u64,
    pub misses: u64,
    pub evictions: u64,
    pub stores: u64,
    pub invalidations: u64,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
#[cfg(all(target_pointer_width = "64", not(target_os = "windows")))]
const _: () = {
    ["Size of nwep_cache_stats"][::std::mem::size_of::<nwep_cache_stats>() - 40usize];
    ["Alignment of nwep_cache_stats"][::std::mem::align_of::<nwep_cache_stats>() - 8usize];
    ["Offset of field: nwep_cache_stats::hits"]
        [::std::mem::offset_of!(nwep_cache_stats, hits) - 0usize];
    ["Offset of field: nwep_cache_stats::misses"]
        [::std::mem::offset_of!(nwep_cache_stats, misses) - 8usize];
    ["Offset of field: nwep_cache_stats::evictions"]
        [::std::mem::offset_of!(nwep_cache_stats, evictions) - 16usize];
    ["Offset of field: nwep_cache_stats::stores"]
        [::std::mem::offset_of!(nwep_cache_stats, stores) - 24usize];
    ["Offset of field: nwep_cache_stats::invalidations"]
        [::std::mem::offset_of!(nwep_cache_stats, invalidations) - 32usize];
};
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_identity_cache_get_stats` gets cache statistics."]
    pub fn nwep_identity_cache_get_stats(
        cache: *const nwep_identity_cache,
        stats: *mut nwep_cache_stats,
    );
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_identity_cache_reset_stats` resets cache statistics."]
    pub fn nwep_identity_cache_reset_stats(cache: *mut nwep_identity_cache);
}
