wolfcose-sys 0.1.0

Low-level unsafe Rust bindings for wolfSSL wolfCOSE.
//! Low-level unsafe bindings for wolfSSL wolfCOSE.
//!
//! Most items in this crate are generated from `wolfcose/wolfcose.h`.
//! Callers are responsible for respecting the C API's pointer, lifetime, and
//! feature-gate requirements.

#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
#![allow(non_upper_case_globals)]
#![allow(improper_ctypes)]
#![allow(missing_docs)]
#![allow(clippy::missing_safety_doc)]
#![allow(clippy::ptr_offset_with_cast)]
#![allow(clippy::useless_transmute)]
#![no_std]

include!(concat!(env!("OUT_DIR"), "/bindings.rs"));

/// Return the CBOR major type at the decoder cursor without advancing it.
///
/// This mirrors the C inline `wc_CBOR_PeekType`, which bindgen cannot expose
/// portably as an extern function.
///
/// # Safety
///
/// `ctx` must be a valid pointer to a `WOLFCOSE_CBOR_CTX`, `ctx.cbuf` must be
/// valid for `ctx.bufSz` bytes, and `ctx.idx` must be less than `ctx.bufSz`.
pub unsafe fn wc_CBOR_PeekType_Rust(ctx: *const WOLFCOSE_CBOR_CTX) -> u8 {
    // SAFETY: The caller upholds validity of `ctx`, `cbuf`, and `idx`.
    unsafe { ((*(*ctx).cbuf.add((*ctx).idx)) as u32 >> 5) as u8 }
}