objc2_latent_semantic_mapping/generated/
mod.rs

1// This file has been automatically generated by `objc2`'s `header-translator`.
2// DO NOT EDIT
3
4#![allow(unused_imports)]
5#![allow(deprecated)]
6#![allow(non_snake_case)]
7#![allow(non_camel_case_types)]
8#![allow(non_upper_case_globals)]
9#![allow(missing_docs)]
10#![allow(clippy::too_many_arguments)]
11#![allow(clippy::type_complexity)]
12#![allow(clippy::upper_case_acronyms)]
13#![allow(clippy::identity_op)]
14#![allow(clippy::missing_safety_doc)]
15#![allow(clippy::doc_lazy_continuation)]
16#![allow(rustdoc::broken_intra_doc_links)]
17#![allow(rustdoc::bare_urls)]
18#![allow(rustdoc::invalid_html_tags)]
19
20#[link(name = "LatentSemanticMapping", kind = "framework")]
21extern "C" {}
22
23use core::cell::UnsafeCell;
24use core::ffi::*;
25use core::marker::{PhantomData, PhantomPinned};
26use core::ptr::NonNull;
27#[cfg(feature = "objc2")]
28use objc2::__framework_prelude::*;
29use objc2_core_foundation::*;
30
31use crate::*;
32
33/// [Apple's documentation](https://developer.apple.com/documentation/latentsemanticmapping/klsmmapoutofstate?language=objc)
34pub const kLSMMapOutOfState: c_int = -6640;
35/// [Apple's documentation](https://developer.apple.com/documentation/latentsemanticmapping/klsmmapnosuchcategory?language=objc)
36pub const kLSMMapNoSuchCategory: c_int = -6641;
37/// [Apple's documentation](https://developer.apple.com/documentation/latentsemanticmapping/klsmmapwriteerror?language=objc)
38pub const kLSMMapWriteError: c_int = -6642;
39/// [Apple's documentation](https://developer.apple.com/documentation/latentsemanticmapping/klsmmapbadpath?language=objc)
40pub const kLSMMapBadPath: c_int = -6643;
41/// [Apple's documentation](https://developer.apple.com/documentation/latentsemanticmapping/klsmmapbadcluster?language=objc)
42pub const kLSMMapBadCluster: c_int = -6644;
43/// [Apple's documentation](https://developer.apple.com/documentation/latentsemanticmapping/klsmmapoverflow?language=objc)
44pub const kLSMMapOverflow: c_int = -6645;
45
46/// An opaque Core Foundation type representing an LSM map (mutable).
47///
48/// See also [Apple's documentation](https://developer.apple.com/documentation/latentsemanticmapping/lsmmap?language=objc)
49#[doc(alias = "LSMMapRef")]
50#[repr(C)]
51pub struct LSMMap {
52    inner: [u8; 0],
53    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
54}
55
56cf_type!(
57    unsafe impl LSMMap {}
58);
59#[cfg(feature = "objc2")]
60cf_objc2_type!(
61    unsafe impl RefEncode<"__LSMMap"> for LSMMap {}
62);
63
64unsafe impl ConcreteType for LSMMap {
65    /// Returns the Core Foundation type identifier for LSM maps.
66    #[doc(alias = "LSMMapGetTypeID")]
67    #[inline]
68    fn type_id() -> CFTypeID {
69        extern "C-unwind" {
70            fn LSMMapGetTypeID() -> CFTypeID;
71        }
72        unsafe { LSMMapGetTypeID() }
73    }
74}
75
76/// An opaque Core Foundation type representing an input text (mutable).
77///
78/// See also [Apple's documentation](https://developer.apple.com/documentation/latentsemanticmapping/lsmtext?language=objc)
79#[doc(alias = "LSMTextRef")]
80#[repr(C)]
81pub struct LSMText {
82    inner: [u8; 0],
83    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
84}
85
86cf_type!(
87    unsafe impl LSMText {}
88);
89#[cfg(feature = "objc2")]
90cf_objc2_type!(
91    unsafe impl RefEncode<"__LSMText"> for LSMText {}
92);
93
94unsafe impl ConcreteType for LSMText {
95    /// Returns the Core Foundation type identifier for LSM texts.
96    #[doc(alias = "LSMTextGetTypeID")]
97    #[inline]
98    fn type_id() -> CFTypeID {
99        extern "C-unwind" {
100            fn LSMTextGetTypeID() -> CFTypeID;
101        }
102        unsafe { LSMTextGetTypeID() }
103    }
104}
105
106/// An opaque Core Foundation type representing the result of a lookup (immutable).
107///
108/// See also [Apple's documentation](https://developer.apple.com/documentation/latentsemanticmapping/lsmresult?language=objc)
109#[doc(alias = "LSMResultRef")]
110#[repr(C)]
111pub struct LSMResult {
112    inner: [u8; 0],
113    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
114}
115
116cf_type!(
117    unsafe impl LSMResult {}
118);
119#[cfg(feature = "objc2")]
120cf_objc2_type!(
121    unsafe impl RefEncode<"__LSMResult"> for LSMResult {}
122);
123
124unsafe impl ConcreteType for LSMResult {
125    /// Returns the Core Foundation type identifier for LSM results.
126    #[doc(alias = "LSMResultGetTypeID")]
127    #[inline]
128    fn type_id() -> CFTypeID {
129        extern "C-unwind" {
130            fn LSMResultGetTypeID() -> CFTypeID;
131        }
132        unsafe { LSMResultGetTypeID() }
133    }
134}
135
136/// An integral type representing a category.
137///
138/// See also [Apple's documentation](https://developer.apple.com/documentation/latentsemanticmapping/lsmcategory?language=objc)
139pub type LSMCategory = u32;
140
141impl LSMMap {
142    /// Creates a new LSM map. Call CFRelease to dispose.
143    #[doc(alias = "LSMMapCreate")]
144    #[inline]
145    pub unsafe fn new(alloc: Option<&CFAllocator>, flags: CFOptionFlags) -> CFRetained<LSMMap> {
146        extern "C-unwind" {
147            fn LSMMapCreate(
148                alloc: Option<&CFAllocator>,
149                flags: CFOptionFlags,
150            ) -> Option<NonNull<LSMMap>>;
151        }
152        let ret = unsafe { LSMMapCreate(alloc, flags) };
153        let ret =
154            ret.expect("function was marked as returning non-null, but actually returned NULL");
155        unsafe { CFRetained::from_raw(ret) }
156    }
157}
158
159/// [Apple's documentation](https://developer.apple.com/documentation/latentsemanticmapping/klsmmappairs?language=objc)
160pub const kLSMMapPairs: c_uint = 1;
161/// [Apple's documentation](https://developer.apple.com/documentation/latentsemanticmapping/klsmmaptriplets?language=objc)
162pub const kLSMMapTriplets: c_uint = 2;
163/// [Apple's documentation](https://developer.apple.com/documentation/latentsemanticmapping/klsmmaphashtext?language=objc)
164pub const kLSMMapHashText: c_uint = 256;
165
166impl LSMMap {
167    /// Set a dictionary of properties for the map. LSM makes its own copy
168    /// of the properties, there's no need to retain them past this call.
169    ///
170    /// # Safety
171    ///
172    /// `properties` generics must be of the correct type.
173    #[doc(alias = "LSMMapSetProperties")]
174    #[inline]
175    pub unsafe fn set_properties(&self, properties: &CFDictionary) {
176        extern "C-unwind" {
177            fn LSMMapSetProperties(mapref: &LSMMap, properties: &CFDictionary);
178        }
179        unsafe { LSMMapSetProperties(self, properties) }
180    }
181
182    /// Get a dictionary of properties for the map. LSM retains ownership of
183    /// this dictionary, do not release it.
184    #[doc(alias = "LSMMapGetProperties")]
185    #[inline]
186    pub unsafe fn properties(&self) -> CFRetained<CFDictionary> {
187        extern "C-unwind" {
188            fn LSMMapGetProperties(mapref: &LSMMap) -> Option<NonNull<CFDictionary>>;
189        }
190        let ret = unsafe { LSMMapGetProperties(self) };
191        let ret =
192            ret.expect("function was marked as returning non-null, but actually returned NULL");
193        unsafe { CFRetained::retain(ret) }
194    }
195
196    /// Puts the map into training mode, preparing it for the addition of more
197    /// categories and/or texts. This function will be somewhat expensive, as it
198    /// requires substantial data structure reorganization.
199    #[doc(alias = "LSMMapStartTraining")]
200    #[inline]
201    pub unsafe fn start_training(&self) -> OSStatus {
202        extern "C-unwind" {
203            fn LSMMapStartTraining(mapref: &LSMMap) -> OSStatus;
204        }
205        unsafe { LSMMapStartTraining(self) }
206    }
207
208    /// Adds another category and returns its category identifier.
209    #[doc(alias = "LSMMapAddCategory")]
210    #[inline]
211    pub unsafe fn add_category(&self) -> LSMCategory {
212        extern "C-unwind" {
213            fn LSMMapAddCategory(mapref: &LSMMap) -> LSMCategory;
214        }
215        unsafe { LSMMapAddCategory(self) }
216    }
217
218    /// Returns the number of categories in the map.
219    #[doc(alias = "LSMMapGetCategoryCount")]
220    #[inline]
221    pub unsafe fn category_count(&self) -> CFIndex {
222        extern "C-unwind" {
223            fn LSMMapGetCategoryCount(mapref: &LSMMap) -> CFIndex;
224        }
225        unsafe { LSMMapGetCategoryCount(self) }
226    }
227
228    /// The specified words will be omitted from all classification efforts.
229    /// Needs to be called before any other texts are created.
230    /// The textref is no longer needed after this call.
231    #[doc(alias = "LSMMapSetStopWords")]
232    #[inline]
233    pub unsafe fn set_stop_words(&self, textref: &LSMText) -> OSStatus {
234        extern "C-unwind" {
235            fn LSMMapSetStopWords(mapref: &LSMMap, textref: &LSMText) -> OSStatus;
236        }
237        unsafe { LSMMapSetStopWords(self, textref) }
238    }
239
240    /// Adds a training text to the given category.
241    /// The textref is no longer needed after this call.
242    #[doc(alias = "LSMMapAddText")]
243    #[inline]
244    pub unsafe fn add_text(&self, textref: &LSMText, category: LSMCategory) -> OSStatus {
245        extern "C-unwind" {
246            fn LSMMapAddText(mapref: &LSMMap, textref: &LSMText, category: LSMCategory)
247                -> OSStatus;
248        }
249        unsafe { LSMMapAddText(self, textref, category) }
250    }
251
252    /// Adds a training text to the given category with a weight different from 1.
253    /// The weight may be negative, but global counts will be pinned to 0.
254    /// The textref is no longer needed after this call.
255    #[doc(alias = "LSMMapAddTextWithWeight")]
256    #[inline]
257    pub unsafe fn add_text_with_weight(
258        &self,
259        textref: &LSMText,
260        category: LSMCategory,
261        weight: c_float,
262    ) -> OSStatus {
263        extern "C-unwind" {
264            fn LSMMapAddTextWithWeight(
265                mapref: &LSMMap,
266                textref: &LSMText,
267                category: LSMCategory,
268                weight: c_float,
269            ) -> OSStatus;
270        }
271        unsafe { LSMMapAddTextWithWeight(self, textref, category, weight) }
272    }
273
274    /// Compiles the map into executable form and puts it into mapping mode,
275    /// preparing it for the classification of texts. This function is
276    /// computationally expensive.
277    #[doc(alias = "LSMMapCompile")]
278    #[inline]
279    pub unsafe fn compile(&self) -> OSStatus {
280        extern "C-unwind" {
281            fn LSMMapCompile(mapref: &LSMMap) -> OSStatus;
282        }
283        unsafe { LSMMapCompile(self) }
284    }
285
286    /// Compute a set of clusters grouping similar categories or words.
287    /// If subset is non-NULL, only perform clustering on the categories
288    /// or words listed.
289    ///
290    /// # Safety
291    ///
292    /// `subset` generic must be of the correct type.
293    #[doc(alias = "LSMMapCreateClusters")]
294    #[inline]
295    pub unsafe fn new_clusters(
296        alloc: Option<&CFAllocator>,
297        mapref: &LSMMap,
298        subset: Option<&CFArray>,
299        num_clusters: CFIndex,
300        flags: CFOptionFlags,
301    ) -> Option<CFRetained<CFArray>> {
302        extern "C-unwind" {
303            fn LSMMapCreateClusters(
304                alloc: Option<&CFAllocator>,
305                mapref: &LSMMap,
306                subset: Option<&CFArray>,
307                num_clusters: CFIndex,
308                flags: CFOptionFlags,
309            ) -> Option<NonNull<CFArray>>;
310        }
311        let ret = unsafe { LSMMapCreateClusters(alloc, mapref, subset, num_clusters, flags) };
312        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
313    }
314}
315
316/// [Apple's documentation](https://developer.apple.com/documentation/latentsemanticmapping/klsmclustercategories?language=objc)
317pub const kLSMClusterCategories: c_uint = 0;
318/// [Apple's documentation](https://developer.apple.com/documentation/latentsemanticmapping/klsmclusterwords?language=objc)
319pub const kLSMClusterWords: c_uint = 1;
320/// [Apple's documentation](https://developer.apple.com/documentation/latentsemanticmapping/klsmclustertokens?language=objc)
321pub const kLSMClusterTokens: c_uint = 2;
322/// [Apple's documentation](https://developer.apple.com/documentation/latentsemanticmapping/klsmclusterkmeans?language=objc)
323pub const kLSMClusterKMeans: c_uint = 0;
324/// [Apple's documentation](https://developer.apple.com/documentation/latentsemanticmapping/klsmclusteragglomerative?language=objc)
325pub const kLSMClusterAgglomerative: c_uint = 4;
326
327impl LSMMap {
328    /// Group categories or words (tokens) into the specified sets of clusters.
329    ///
330    /// # Safety
331    ///
332    /// `clusters` generic must be of the correct type.
333    #[doc(alias = "LSMMapApplyClusters")]
334    #[inline]
335    pub unsafe fn apply_clusters(&self, clusters: &CFArray) -> OSStatus {
336        extern "C-unwind" {
337            fn LSMMapApplyClusters(mapref: &LSMMap, clusters: &CFArray) -> OSStatus;
338        }
339        unsafe { LSMMapApplyClusters(self, clusters) }
340    }
341}
342
343impl LSMResult {
344    /// Returns, in decreasing order of likelihood, the categories or words
345    /// that best match when a text is mapped into a map.
346    #[doc(alias = "LSMResultCreate")]
347    #[inline]
348    pub unsafe fn new(
349        alloc: Option<&CFAllocator>,
350        mapref: &LSMMap,
351        textref: &LSMText,
352        num_results: CFIndex,
353        flags: CFOptionFlags,
354    ) -> CFRetained<LSMResult> {
355        extern "C-unwind" {
356            fn LSMResultCreate(
357                alloc: Option<&CFAllocator>,
358                mapref: &LSMMap,
359                textref: &LSMText,
360                num_results: CFIndex,
361                flags: CFOptionFlags,
362            ) -> Option<NonNull<LSMResult>>;
363        }
364        let ret = unsafe { LSMResultCreate(alloc, mapref, textref, num_results, flags) };
365        let ret =
366            ret.expect("function was marked as returning non-null, but actually returned NULL");
367        unsafe { CFRetained::from_raw(ret) }
368    }
369}
370
371/// [Apple's documentation](https://developer.apple.com/documentation/latentsemanticmapping/klsmresultbestwords?language=objc)
372pub const kLSMResultBestWords: c_uint = 1;
373
374impl LSMResult {
375    /// Returns the number of results.
376    #[doc(alias = "LSMResultGetCount")]
377    #[inline]
378    pub unsafe fn count(&self) -> CFIndex {
379        extern "C-unwind" {
380            fn LSMResultGetCount(result: &LSMResult) -> CFIndex;
381        }
382        unsafe { LSMResultGetCount(self) }
383    }
384
385    /// Returns the category of the n-th best (zero based) result.
386    #[doc(alias = "LSMResultGetCategory")]
387    #[inline]
388    pub unsafe fn category(&self, n: CFIndex) -> LSMCategory {
389        extern "C-unwind" {
390            fn LSMResultGetCategory(result: &LSMResult, n: CFIndex) -> LSMCategory;
391        }
392        unsafe { LSMResultGetCategory(self, n) }
393    }
394
395    /// Returns the likelihood of the n-th best (zero based) result.
396    /// A nan score often indicates that the category does not contain
397    /// any token.
398    #[doc(alias = "LSMResultGetScore")]
399    #[inline]
400    pub unsafe fn score(&self, n: CFIndex) -> c_float {
401        extern "C-unwind" {
402            fn LSMResultGetScore(result: &LSMResult, n: CFIndex) -> c_float;
403        }
404        unsafe { LSMResultGetScore(self, n) }
405    }
406
407    /// Returns the word for the n-th best (zero based) result.
408    #[doc(alias = "LSMResultCopyWord")]
409    #[inline]
410    pub unsafe fn word(&self, n: CFIndex) -> Option<CFRetained<CFString>> {
411        extern "C-unwind" {
412            fn LSMResultCopyWord(result: &LSMResult, n: CFIndex) -> Option<NonNull<CFString>>;
413        }
414        let ret = unsafe { LSMResultCopyWord(self, n) };
415        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
416    }
417
418    /// Returns the token for the n-th best (zero based) result.
419    #[doc(alias = "LSMResultCopyToken")]
420    #[inline]
421    pub unsafe fn token(&self, n: CFIndex) -> Option<CFRetained<CFData>> {
422        extern "C-unwind" {
423            fn LSMResultCopyToken(result: &LSMResult, n: CFIndex) -> Option<NonNull<CFData>>;
424        }
425        let ret = unsafe { LSMResultCopyToken(self, n) };
426        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
427    }
428
429    /// Returns the cluster of words for the n-th best (zero based) result.
430    #[doc(alias = "LSMResultCopyWordCluster")]
431    #[inline]
432    pub unsafe fn word_cluster(&self, n: CFIndex) -> Option<CFRetained<CFArray>> {
433        extern "C-unwind" {
434            fn LSMResultCopyWordCluster(result: &LSMResult, n: CFIndex)
435                -> Option<NonNull<CFArray>>;
436        }
437        let ret = unsafe { LSMResultCopyWordCluster(self, n) };
438        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
439    }
440
441    /// Returns the cluster of tokens for the n-th best (zero based) result.
442    #[doc(alias = "LSMResultCopyTokenCluster")]
443    #[inline]
444    pub unsafe fn token_cluster(&self, n: CFIndex) -> Option<CFRetained<CFArray>> {
445        extern "C-unwind" {
446            fn LSMResultCopyTokenCluster(
447                result: &LSMResult,
448                n: CFIndex,
449            ) -> Option<NonNull<CFArray>>;
450        }
451        let ret = unsafe { LSMResultCopyTokenCluster(self, n) };
452        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
453    }
454}
455
456impl LSMMap {
457    /// Compiles the map if necessary and then stores it into the given file.
458    #[doc(alias = "LSMMapWriteToURL")]
459    #[inline]
460    pub unsafe fn write_to_url(&self, file: &CFURL, flags: CFOptionFlags) -> OSStatus {
461        extern "C-unwind" {
462            fn LSMMapWriteToURL(mapref: &LSMMap, file: &CFURL, flags: CFOptionFlags) -> OSStatus;
463        }
464        unsafe { LSMMapWriteToURL(self, file, flags) }
465    }
466
467    /// Loads a map from a given file.
468    #[doc(alias = "LSMMapCreateFromURL")]
469    #[inline]
470    pub unsafe fn from_url(
471        alloc: Option<&CFAllocator>,
472        file: &CFURL,
473        flags: CFOptionFlags,
474    ) -> Option<CFRetained<LSMMap>> {
475        extern "C-unwind" {
476            fn LSMMapCreateFromURL(
477                alloc: Option<&CFAllocator>,
478                file: &CFURL,
479                flags: CFOptionFlags,
480            ) -> Option<NonNull<LSMMap>>;
481        }
482        let ret = unsafe { LSMMapCreateFromURL(alloc, file, flags) };
483        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
484    }
485}
486
487/// [Apple's documentation](https://developer.apple.com/documentation/latentsemanticmapping/klsmmapdiscardcounts?language=objc)
488pub const kLSMMapDiscardCounts: c_uint = 1;
489/// [Apple's documentation](https://developer.apple.com/documentation/latentsemanticmapping/klsmmaploadmutable?language=objc)
490pub const kLSMMapLoadMutable: c_uint = 2;
491
492impl LSMMap {
493    /// Writes information about a map and/or text to a stream in text form
494    #[doc(alias = "LSMMapWriteToStream")]
495    #[inline]
496    pub unsafe fn write_to_stream(
497        &self,
498        textref: Option<&LSMText>,
499        stream: &CFWriteStream,
500        options: CFOptionFlags,
501    ) -> OSStatus {
502        extern "C-unwind" {
503            fn LSMMapWriteToStream(
504                mapref: &LSMMap,
505                textref: Option<&LSMText>,
506                stream: &CFWriteStream,
507                options: CFOptionFlags,
508            ) -> OSStatus;
509        }
510        unsafe { LSMMapWriteToStream(self, textref, stream, options) }
511    }
512}
513
514impl LSMText {
515    /// Creates a new text.
516    #[doc(alias = "LSMTextCreate")]
517    #[inline]
518    pub unsafe fn new(alloc: Option<&CFAllocator>, mapref: &LSMMap) -> CFRetained<LSMText> {
519        extern "C-unwind" {
520            fn LSMTextCreate(
521                alloc: Option<&CFAllocator>,
522                mapref: &LSMMap,
523            ) -> Option<NonNull<LSMText>>;
524        }
525        let ret = unsafe { LSMTextCreate(alloc, mapref) };
526        let ret =
527            ret.expect("function was marked as returning non-null, but actually returned NULL");
528        unsafe { CFRetained::from_raw(ret) }
529    }
530
531    /// Adds a word to the text. The order of words is significant if the map
532    /// uses pairs or triplets, and the count of words is always significant.
533    #[doc(alias = "LSMTextAddWord")]
534    #[inline]
535    pub unsafe fn add_word(&self, word: &CFString) -> OSStatus {
536        extern "C-unwind" {
537            fn LSMTextAddWord(textref: &LSMText, word: &CFString) -> OSStatus;
538        }
539        unsafe { LSMTextAddWord(self, word) }
540    }
541
542    /// Breaks a string into words using the locale provided and adds the words
543    /// to the text.
544    #[doc(alias = "LSMTextAddWords")]
545    #[inline]
546    pub unsafe fn add_words(
547        &self,
548        words: &CFString,
549        locale: Option<&CFLocale>,
550        flags: CFOptionFlags,
551    ) -> OSStatus {
552        extern "C-unwind" {
553            fn LSMTextAddWords(
554                textref: &LSMText,
555                words: &CFString,
556                locale: Option<&CFLocale>,
557                flags: CFOptionFlags,
558            ) -> OSStatus;
559        }
560        unsafe { LSMTextAddWords(self, words, locale, flags) }
561    }
562}
563
564/// [Apple's documentation](https://developer.apple.com/documentation/latentsemanticmapping/klsmtextpreservecase?language=objc)
565pub const kLSMTextPreserveCase: c_uint = 1;
566/// [Apple's documentation](https://developer.apple.com/documentation/latentsemanticmapping/klsmtextpreserveacronyms?language=objc)
567pub const kLSMTextPreserveAcronyms: c_uint = 2;
568/// [Apple's documentation](https://developer.apple.com/documentation/latentsemanticmapping/klsmtextapplyspamheuristics?language=objc)
569pub const kLSMTextApplySpamHeuristics: c_uint = 4;
570
571impl LSMText {
572    /// Adds an arbitrary binary token to the text. The order of tokens is
573    /// significant if the map uses pairs or triplets, and the count of
574    /// tokens is always significant.
575    #[doc(alias = "LSMTextAddToken")]
576    #[inline]
577    pub unsafe fn add_token(&self, token: &CFData) -> OSStatus {
578        extern "C-unwind" {
579            fn LSMTextAddToken(textref: &LSMText, token: &CFData) -> OSStatus;
580        }
581        unsafe { LSMTextAddToken(self, token) }
582    }
583}
584
585#[deprecated = "renamed to `LSMMap::new`"]
586#[inline]
587pub unsafe extern "C-unwind" fn LSMMapCreate(
588    alloc: Option<&CFAllocator>,
589    flags: CFOptionFlags,
590) -> CFRetained<LSMMap> {
591    extern "C-unwind" {
592        fn LSMMapCreate(
593            alloc: Option<&CFAllocator>,
594            flags: CFOptionFlags,
595        ) -> Option<NonNull<LSMMap>>;
596    }
597    let ret = unsafe { LSMMapCreate(alloc, flags) };
598    let ret = ret.expect("function was marked as returning non-null, but actually returned NULL");
599    unsafe { CFRetained::from_raw(ret) }
600}
601
602extern "C-unwind" {
603    #[deprecated = "renamed to `LSMMap::set_properties`"]
604    pub fn LSMMapSetProperties(mapref: &LSMMap, properties: &CFDictionary);
605}
606
607#[deprecated = "renamed to `LSMMap::properties`"]
608#[inline]
609pub unsafe extern "C-unwind" fn LSMMapGetProperties(mapref: &LSMMap) -> CFRetained<CFDictionary> {
610    extern "C-unwind" {
611        fn LSMMapGetProperties(mapref: &LSMMap) -> Option<NonNull<CFDictionary>>;
612    }
613    let ret = unsafe { LSMMapGetProperties(mapref) };
614    let ret = ret.expect("function was marked as returning non-null, but actually returned NULL");
615    unsafe { CFRetained::retain(ret) }
616}
617
618extern "C-unwind" {
619    #[deprecated = "renamed to `LSMMap::start_training`"]
620    pub fn LSMMapStartTraining(mapref: &LSMMap) -> OSStatus;
621}
622
623extern "C-unwind" {
624    #[deprecated = "renamed to `LSMMap::add_category`"]
625    pub fn LSMMapAddCategory(mapref: &LSMMap) -> LSMCategory;
626}
627
628extern "C-unwind" {
629    #[deprecated = "renamed to `LSMMap::category_count`"]
630    pub fn LSMMapGetCategoryCount(mapref: &LSMMap) -> CFIndex;
631}
632
633extern "C-unwind" {
634    #[deprecated = "renamed to `LSMMap::set_stop_words`"]
635    pub fn LSMMapSetStopWords(mapref: &LSMMap, textref: &LSMText) -> OSStatus;
636}
637
638extern "C-unwind" {
639    #[deprecated = "renamed to `LSMMap::add_text`"]
640    pub fn LSMMapAddText(mapref: &LSMMap, textref: &LSMText, category: LSMCategory) -> OSStatus;
641}
642
643extern "C-unwind" {
644    #[deprecated = "renamed to `LSMMap::add_text_with_weight`"]
645    pub fn LSMMapAddTextWithWeight(
646        mapref: &LSMMap,
647        textref: &LSMText,
648        category: LSMCategory,
649        weight: c_float,
650    ) -> OSStatus;
651}
652
653extern "C-unwind" {
654    #[deprecated = "renamed to `LSMMap::compile`"]
655    pub fn LSMMapCompile(mapref: &LSMMap) -> OSStatus;
656}
657
658#[deprecated = "renamed to `LSMMap::new_clusters`"]
659#[inline]
660pub unsafe extern "C-unwind" fn LSMMapCreateClusters(
661    alloc: Option<&CFAllocator>,
662    mapref: &LSMMap,
663    subset: Option<&CFArray>,
664    num_clusters: CFIndex,
665    flags: CFOptionFlags,
666) -> Option<CFRetained<CFArray>> {
667    extern "C-unwind" {
668        fn LSMMapCreateClusters(
669            alloc: Option<&CFAllocator>,
670            mapref: &LSMMap,
671            subset: Option<&CFArray>,
672            num_clusters: CFIndex,
673            flags: CFOptionFlags,
674        ) -> Option<NonNull<CFArray>>;
675    }
676    let ret = unsafe { LSMMapCreateClusters(alloc, mapref, subset, num_clusters, flags) };
677    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
678}
679
680extern "C-unwind" {
681    #[deprecated = "renamed to `LSMMap::apply_clusters`"]
682    pub fn LSMMapApplyClusters(mapref: &LSMMap, clusters: &CFArray) -> OSStatus;
683}
684
685#[deprecated = "renamed to `LSMResult::new`"]
686#[inline]
687pub unsafe extern "C-unwind" fn LSMResultCreate(
688    alloc: Option<&CFAllocator>,
689    mapref: &LSMMap,
690    textref: &LSMText,
691    num_results: CFIndex,
692    flags: CFOptionFlags,
693) -> CFRetained<LSMResult> {
694    extern "C-unwind" {
695        fn LSMResultCreate(
696            alloc: Option<&CFAllocator>,
697            mapref: &LSMMap,
698            textref: &LSMText,
699            num_results: CFIndex,
700            flags: CFOptionFlags,
701        ) -> Option<NonNull<LSMResult>>;
702    }
703    let ret = unsafe { LSMResultCreate(alloc, mapref, textref, num_results, flags) };
704    let ret = ret.expect("function was marked as returning non-null, but actually returned NULL");
705    unsafe { CFRetained::from_raw(ret) }
706}
707
708extern "C-unwind" {
709    #[deprecated = "renamed to `LSMResult::count`"]
710    pub fn LSMResultGetCount(result: &LSMResult) -> CFIndex;
711}
712
713extern "C-unwind" {
714    #[deprecated = "renamed to `LSMResult::category`"]
715    pub fn LSMResultGetCategory(result: &LSMResult, n: CFIndex) -> LSMCategory;
716}
717
718extern "C-unwind" {
719    #[deprecated = "renamed to `LSMResult::score`"]
720    pub fn LSMResultGetScore(result: &LSMResult, n: CFIndex) -> c_float;
721}
722
723#[deprecated = "renamed to `LSMResult::word`"]
724#[inline]
725pub unsafe extern "C-unwind" fn LSMResultCopyWord(
726    result: &LSMResult,
727    n: CFIndex,
728) -> Option<CFRetained<CFString>> {
729    extern "C-unwind" {
730        fn LSMResultCopyWord(result: &LSMResult, n: CFIndex) -> Option<NonNull<CFString>>;
731    }
732    let ret = unsafe { LSMResultCopyWord(result, n) };
733    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
734}
735
736#[deprecated = "renamed to `LSMResult::token`"]
737#[inline]
738pub unsafe extern "C-unwind" fn LSMResultCopyToken(
739    result: &LSMResult,
740    n: CFIndex,
741) -> Option<CFRetained<CFData>> {
742    extern "C-unwind" {
743        fn LSMResultCopyToken(result: &LSMResult, n: CFIndex) -> Option<NonNull<CFData>>;
744    }
745    let ret = unsafe { LSMResultCopyToken(result, n) };
746    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
747}
748
749#[deprecated = "renamed to `LSMResult::word_cluster`"]
750#[inline]
751pub unsafe extern "C-unwind" fn LSMResultCopyWordCluster(
752    result: &LSMResult,
753    n: CFIndex,
754) -> Option<CFRetained<CFArray>> {
755    extern "C-unwind" {
756        fn LSMResultCopyWordCluster(result: &LSMResult, n: CFIndex) -> Option<NonNull<CFArray>>;
757    }
758    let ret = unsafe { LSMResultCopyWordCluster(result, n) };
759    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
760}
761
762#[deprecated = "renamed to `LSMResult::token_cluster`"]
763#[inline]
764pub unsafe extern "C-unwind" fn LSMResultCopyTokenCluster(
765    result: &LSMResult,
766    n: CFIndex,
767) -> Option<CFRetained<CFArray>> {
768    extern "C-unwind" {
769        fn LSMResultCopyTokenCluster(result: &LSMResult, n: CFIndex) -> Option<NonNull<CFArray>>;
770    }
771    let ret = unsafe { LSMResultCopyTokenCluster(result, n) };
772    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
773}
774
775extern "C-unwind" {
776    #[deprecated = "renamed to `LSMMap::write_to_url`"]
777    pub fn LSMMapWriteToURL(mapref: &LSMMap, file: &CFURL, flags: CFOptionFlags) -> OSStatus;
778}
779
780#[deprecated = "renamed to `LSMMap::from_url`"]
781#[inline]
782pub unsafe extern "C-unwind" fn LSMMapCreateFromURL(
783    alloc: Option<&CFAllocator>,
784    file: &CFURL,
785    flags: CFOptionFlags,
786) -> Option<CFRetained<LSMMap>> {
787    extern "C-unwind" {
788        fn LSMMapCreateFromURL(
789            alloc: Option<&CFAllocator>,
790            file: &CFURL,
791            flags: CFOptionFlags,
792        ) -> Option<NonNull<LSMMap>>;
793    }
794    let ret = unsafe { LSMMapCreateFromURL(alloc, file, flags) };
795    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
796}
797
798extern "C-unwind" {
799    #[deprecated = "renamed to `LSMMap::write_to_stream`"]
800    pub fn LSMMapWriteToStream(
801        mapref: &LSMMap,
802        textref: Option<&LSMText>,
803        stream: &CFWriteStream,
804        options: CFOptionFlags,
805    ) -> OSStatus;
806}
807
808#[deprecated = "renamed to `LSMText::new`"]
809#[inline]
810pub unsafe extern "C-unwind" fn LSMTextCreate(
811    alloc: Option<&CFAllocator>,
812    mapref: &LSMMap,
813) -> CFRetained<LSMText> {
814    extern "C-unwind" {
815        fn LSMTextCreate(alloc: Option<&CFAllocator>, mapref: &LSMMap) -> Option<NonNull<LSMText>>;
816    }
817    let ret = unsafe { LSMTextCreate(alloc, mapref) };
818    let ret = ret.expect("function was marked as returning non-null, but actually returned NULL");
819    unsafe { CFRetained::from_raw(ret) }
820}
821
822extern "C-unwind" {
823    #[deprecated = "renamed to `LSMText::add_word`"]
824    pub fn LSMTextAddWord(textref: &LSMText, word: &CFString) -> OSStatus;
825}
826
827extern "C-unwind" {
828    #[deprecated = "renamed to `LSMText::add_words`"]
829    pub fn LSMTextAddWords(
830        textref: &LSMText,
831        words: &CFString,
832        locale: Option<&CFLocale>,
833        flags: CFOptionFlags,
834    ) -> OSStatus;
835}
836
837extern "C-unwind" {
838    #[deprecated = "renamed to `LSMText::add_token`"]
839    pub fn LSMTextAddToken(textref: &LSMText, token: &CFData) -> OSStatus;
840}