objc2-security 0.3.2

Bindings to the Security framework
Documentation
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::cell::UnsafeCell;
use core::ffi::*;
use core::marker::{PhantomData, PhantomPinned};
use core::ptr::NonNull;
#[cfg(feature = "objc2")]
use objc2::__framework_prelude::*;

use crate::*;

/// [Apple's documentation](https://developer.apple.com/documentation/security/__secrandom?language=objc)
#[repr(C)]
#[derive(Debug)]
pub struct __SecRandom {
    inner: [u8; 0],
    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
}

#[cfg(feature = "objc2")]
unsafe impl RefEncode for __SecRandom {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Encoding::Struct("__SecRandom", &[]));
}

/// Reference to a (pseudo) random number generator.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/security/secrandomref?language=objc)
pub type SecRandomRef = *const __SecRandom;

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/security/ksecrandomdefault?language=objc)
    pub static kSecRandomDefault: SecRandomRef;
}

extern "C-unwind" {
    /// Return count random bytes in *bytes, allocated by the caller. It
    /// is critical to check the return value for error.
    ///
    ///
    /// Parameter `rnd`: Only
    /// `kSecRandomDefault`is supported.
    ///
    ///
    /// Parameter `count`: The number of bytes to generate.
    ///
    ///
    /// Parameter `bytes`: A buffer to fill with random output.
    ///
    ///
    /// Returns: Return 0 on success, any other value on failure.
    ///
    ///
    /// If
    /// `rnd`is unrecognized or unsupported,
    /// `kSecRandomDefault`is
    /// used.
    ///
    /// # Safety
    ///
    /// - `rnd` must be a valid pointer or null.
    /// - `bytes` must be a valid pointer.
    #[must_use]
    pub fn SecRandomCopyBytes(rnd: SecRandomRef, count: usize, bytes: NonNull<c_void>) -> c_int;
}