1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
//! 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;
}