objc2_security/generated/
SecRandom.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::cell::UnsafeCell;
4use core::ffi::*;
5use core::marker::{PhantomData, PhantomPinned};
6use core::ptr::NonNull;
7#[cfg(feature = "objc2")]
8use objc2::__framework_prelude::*;
9
10use crate::*;
11
12/// [Apple's documentation](https://developer.apple.com/documentation/security/__secrandom?language=objc)
13#[repr(C)]
14#[derive(Debug)]
15pub struct __SecRandom {
16    inner: [u8; 0],
17    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
18}
19
20#[cfg(feature = "objc2")]
21unsafe impl RefEncode for __SecRandom {
22    const ENCODING_REF: Encoding = Encoding::Pointer(&Encoding::Struct("__SecRandom", &[]));
23}
24
25/// Reference to a (pseudo) random number generator.
26///
27/// See also [Apple's documentation](https://developer.apple.com/documentation/security/secrandomref?language=objc)
28pub type SecRandomRef = *const __SecRandom;
29
30extern "C" {
31    /// [Apple's documentation](https://developer.apple.com/documentation/security/ksecrandomdefault?language=objc)
32    pub static kSecRandomDefault: SecRandomRef;
33}
34
35extern "C-unwind" {
36    /// Return count random bytes in *bytes, allocated by the caller. It
37    /// is critical to check the return value for error.
38    ///
39    ///
40    /// Parameter `rnd`: Only
41    /// `kSecRandomDefault`is supported.
42    ///
43    ///
44    /// Parameter `count`: The number of bytes to generate.
45    ///
46    ///
47    /// Parameter `bytes`: A buffer to fill with random output.
48    ///
49    ///
50    /// Returns: Return 0 on success, any other value on failure.
51    ///
52    ///
53    /// If
54    /// `rnd`is unrecognized or unsupported,
55    /// `kSecRandomDefault`is
56    /// used.
57    ///
58    /// # Safety
59    ///
60    /// - `rnd` must be a valid pointer or null.
61    /// - `bytes` must be a valid pointer.
62    #[must_use]
63    pub fn SecRandomCopyBytes(rnd: SecRandomRef, count: usize, bytes: NonNull<c_void>) -> c_int;
64}