objc2_core_media/generated/
CMMemoryPool.rs1use core::cell::UnsafeCell;
4use core::ffi::*;
5use core::marker::{PhantomData, PhantomPinned};
6use core::ptr::NonNull;
7#[cfg(feature = "objc2")]
8use objc2::__framework_prelude::*;
9use objc2_core_foundation::*;
10
11use crate::*;
12
13#[doc(alias = "CMMemoryPoolRef")]
44#[repr(C)]
45pub struct CMMemoryPool {
46 inner: [u8; 0],
47 _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
48}
49
50cf_type!(
51 unsafe impl CMMemoryPool {}
52);
53#[cfg(feature = "objc2")]
54cf_objc2_type!(
55 unsafe impl RefEncode<"OpaqueCMMemoryPool"> for CMMemoryPool {}
56);
57
58unsafe impl Send for CMMemoryPool {}
59
60unsafe impl Sync for CMMemoryPool {}
61
62pub const kCMMemoryPoolError_AllocationFailed: OSStatus = -15490;
64pub const kCMMemoryPoolError_InvalidParameter: OSStatus = -15491;
66
67unsafe impl ConcreteType for CMMemoryPool {
68 #[doc(alias = "CMMemoryPoolGetTypeID")]
69 #[inline]
70 fn type_id() -> CFTypeID {
71 extern "C-unwind" {
72 fn CMMemoryPoolGetTypeID() -> CFTypeID;
73 }
74 unsafe { CMMemoryPoolGetTypeID() }
75 }
76}
77
78extern "C" {
79 pub static kCMMemoryPoolOption_AgeOutPeriod: &'static CFString;
85}
86
87impl CMMemoryPool {
88 #[doc(alias = "CMMemoryPoolCreate")]
94 #[inline]
95 pub unsafe fn new(options: Option<&CFDictionary>) -> CFRetained<CMMemoryPool> {
96 extern "C-unwind" {
97 fn CMMemoryPoolCreate(options: Option<&CFDictionary>) -> Option<NonNull<CMMemoryPool>>;
98 }
99 let ret = unsafe { CMMemoryPoolCreate(options) };
100 let ret =
101 ret.expect("function was marked as returning non-null, but actually returned NULL");
102 unsafe { CFRetained::from_raw(ret) }
103 }
104
105 #[doc(alias = "CMMemoryPoolGetAllocator")]
107 #[inline]
108 pub unsafe fn allocator(&self) -> CFRetained<CFAllocator> {
109 extern "C-unwind" {
110 fn CMMemoryPoolGetAllocator(pool: &CMMemoryPool) -> Option<NonNull<CFAllocator>>;
111 }
112 let ret = unsafe { CMMemoryPoolGetAllocator(self) };
113 let ret =
114 ret.expect("function was marked as returning non-null, but actually returned NULL");
115 unsafe { CFRetained::retain(ret) }
116 }
117
118 #[doc(alias = "CMMemoryPoolFlush")]
120 #[inline]
121 pub unsafe fn flush(&self) {
122 extern "C-unwind" {
123 fn CMMemoryPoolFlush(pool: &CMMemoryPool);
124 }
125 unsafe { CMMemoryPoolFlush(self) }
126 }
127
128 #[doc(alias = "CMMemoryPoolInvalidate")]
135 #[inline]
136 pub unsafe fn invalidate(&self) {
137 extern "C-unwind" {
138 fn CMMemoryPoolInvalidate(pool: &CMMemoryPool);
139 }
140 unsafe { CMMemoryPoolInvalidate(self) }
141 }
142}
143
144#[deprecated = "renamed to `CMMemoryPool::new`"]
145#[inline]
146pub unsafe extern "C-unwind" fn CMMemoryPoolCreate(
147 options: Option<&CFDictionary>,
148) -> CFRetained<CMMemoryPool> {
149 extern "C-unwind" {
150 fn CMMemoryPoolCreate(options: Option<&CFDictionary>) -> Option<NonNull<CMMemoryPool>>;
151 }
152 let ret = unsafe { CMMemoryPoolCreate(options) };
153 let ret = ret.expect("function was marked as returning non-null, but actually returned NULL");
154 unsafe { CFRetained::from_raw(ret) }
155}
156
157#[deprecated = "renamed to `CMMemoryPool::allocator`"]
158#[inline]
159pub unsafe extern "C-unwind" fn CMMemoryPoolGetAllocator(
160 pool: &CMMemoryPool,
161) -> CFRetained<CFAllocator> {
162 extern "C-unwind" {
163 fn CMMemoryPoolGetAllocator(pool: &CMMemoryPool) -> Option<NonNull<CFAllocator>>;
164 }
165 let ret = unsafe { CMMemoryPoolGetAllocator(pool) };
166 let ret = ret.expect("function was marked as returning non-null, but actually returned NULL");
167 unsafe { CFRetained::retain(ret) }
168}
169
170extern "C-unwind" {
171 #[deprecated = "renamed to `CMMemoryPool::flush`"]
172 pub fn CMMemoryPoolFlush(pool: &CMMemoryPool);
173}
174
175extern "C-unwind" {
176 #[deprecated = "renamed to `CMMemoryPool::invalidate`"]
177 pub fn CMMemoryPoolInvalidate(pool: &CMMemoryPool);
178}