objc2_open_directory/generated/CFOpenDirectory/CFODSession.rs
1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ptr::NonNull;
4#[cfg(feature = "objc2-core-foundation")]
5use objc2_core_foundation::*;
6
7use crate::*;
8
9extern "C" {
10 /// is the default type of ODSessionRef used if there is no need to create a specific reference
11 ///
12 /// is the default type of ODSessionRef used if there is no need to create a specific reference
13 ///
14 /// See also [Apple's documentation](https://developer.apple.com/documentation/opendirectory/kodsessiondefault?language=objc)
15 pub static kODSessionDefault: Option<&'static ODSessionRef>;
16}
17
18#[cfg(feature = "objc2-core-foundation")]
19unsafe impl ConcreteType for ODSessionRef {
20 /// Standard GetTypeID function support for CF-based objects
21 ///
22 /// Returns the typeID for ODSession objects
23 ///
24 /// Returns: a valid CFTypeID for the ODSession object
25 #[doc(alias = "ODSessionGetTypeID")]
26 #[inline]
27 fn type_id() -> CFTypeID {
28 extern "C-unwind" {
29 fn ODSessionGetTypeID() -> CFTypeID;
30 }
31 unsafe { ODSessionGetTypeID() }
32 }
33}
34
35impl ODSessionRef {
36 /// Creates an ODSession object to be passed to ODNode functions
37 ///
38 /// Creates an ODSession object to be passed to ODNode functions.
39 ///
40 /// Parameter `allocator`: a memory allocator to use for this object
41 ///
42 /// Parameter `options`: a CFDictionary of options associated with this ODSession. This is typically NULL
43 /// unless caller needs to proxy to another host.
44 ///
45 /// If proxy is required then a dictionary with keys should be:
46 /// Key Value
47 /// kODSessionProxyAddress CFString(hostname or IP)
48 /// kODSessionProxyPort CFNumber(IP port, should not be set as it will default)
49 /// kODSessionProxyUsername CFString(username)
50 /// kODSessionProxyPassword CFString(password)
51 ///
52 /// Parameter `error`: an optional CFErrorRef reference for error details
53 ///
54 /// Returns: a valid ODSessionRef object or NULL if it cannot be created. Pass reference to CFErrorRef to
55 /// get error details
56 ///
57 /// # Safety
58 ///
59 /// - `allocator` might not allow `None`.
60 /// - `options` generics must be of the correct type.
61 /// - `options` might not allow `None`.
62 /// - `error` must be a valid pointer.
63 #[doc(alias = "ODSessionCreate")]
64 #[cfg(feature = "objc2-core-foundation")]
65 #[inline]
66 pub unsafe fn new(
67 allocator: Option<&CFAllocator>,
68 options: Option<&CFDictionary>,
69 error: *mut *mut CFError,
70 ) -> Option<CFRetained<ODSessionRef>> {
71 extern "C-unwind" {
72 fn ODSessionCreate(
73 allocator: Option<&CFAllocator>,
74 options: Option<&CFDictionary>,
75 error: *mut *mut CFError,
76 ) -> Option<NonNull<ODSessionRef>>;
77 }
78 let ret = unsafe { ODSessionCreate(allocator, options, error) };
79 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
80 }
81
82 /// Returns the node names that are registered on this ODSession
83 ///
84 /// Returns the node names that are registered on this ODSession
85 ///
86 /// Parameter `allocator`: a memory allocator to use for this object
87 ///
88 /// Parameter `session`: an ODSessionRef, either kODSessionDefault or a valid ODSessionRef can be passed
89 ///
90 /// Parameter `error`: an optional CFErrorRef reference for error details
91 ///
92 /// Returns: a valid CFArrayRef of node names that can be opened on the session reference
93 ///
94 /// # Safety
95 ///
96 /// - `allocator` might not allow `None`.
97 /// - `session` might not allow `None`.
98 /// - `error` must be a valid pointer.
99 #[doc(alias = "ODSessionCopyNodeNames")]
100 #[cfg(feature = "objc2-core-foundation")]
101 #[inline]
102 pub unsafe fn node_names(
103 allocator: Option<&CFAllocator>,
104 session: Option<&ODSessionRef>,
105 error: *mut *mut CFError,
106 ) -> Option<CFRetained<CFArray>> {
107 extern "C-unwind" {
108 fn ODSessionCopyNodeNames(
109 allocator: Option<&CFAllocator>,
110 session: Option<&ODSessionRef>,
111 error: *mut *mut CFError,
112 ) -> Option<NonNull<CFArray>>;
113 }
114 let ret = unsafe { ODSessionCopyNodeNames(allocator, session, error) };
115 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
116 }
117}
118
119#[cfg(feature = "objc2-core-foundation")]
120#[deprecated = "renamed to `ODSessionRef::new`"]
121#[inline]
122pub unsafe extern "C-unwind" fn ODSessionCreate(
123 allocator: Option<&CFAllocator>,
124 options: Option<&CFDictionary>,
125 error: *mut *mut CFError,
126) -> Option<CFRetained<ODSessionRef>> {
127 extern "C-unwind" {
128 fn ODSessionCreate(
129 allocator: Option<&CFAllocator>,
130 options: Option<&CFDictionary>,
131 error: *mut *mut CFError,
132 ) -> Option<NonNull<ODSessionRef>>;
133 }
134 let ret = unsafe { ODSessionCreate(allocator, options, error) };
135 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
136}
137
138#[cfg(feature = "objc2-core-foundation")]
139#[deprecated = "renamed to `ODSessionRef::node_names`"]
140#[inline]
141pub unsafe extern "C-unwind" fn ODSessionCopyNodeNames(
142 allocator: Option<&CFAllocator>,
143 session: Option<&ODSessionRef>,
144 error: *mut *mut CFError,
145) -> Option<CFRetained<CFArray>> {
146 extern "C-unwind" {
147 fn ODSessionCopyNodeNames(
148 allocator: Option<&CFAllocator>,
149 session: Option<&ODSessionRef>,
150 error: *mut *mut CFError,
151 ) -> Option<NonNull<CFArray>>;
152 }
153 let ret = unsafe { ODSessionCopyNodeNames(allocator, session, error) };
154 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
155}