objc2_foundation/generated/
NSCache.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6
7use crate::*;
8
9extern_class!(
10    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nscache?language=objc)
11    #[unsafe(super(NSObject))]
12    #[derive(Debug, PartialEq, Eq, Hash)]
13    pub struct NSCache<KeyType: ?Sized = AnyObject, ObjectType: ?Sized = AnyObject>;
14);
15
16unsafe impl<KeyType: ?Sized, ObjectType: ?Sized> NSObjectProtocol for NSCache<KeyType, ObjectType> {}
17
18impl<KeyType: Message, ObjectType: Message> NSCache<KeyType, ObjectType> {
19    extern_methods!(
20        #[cfg(feature = "NSString")]
21        #[unsafe(method(name))]
22        #[unsafe(method_family = none)]
23        pub unsafe fn name(&self) -> Retained<NSString>;
24
25        #[cfg(feature = "NSString")]
26        /// Setter for [`name`][Self::name].
27        #[unsafe(method(setName:))]
28        #[unsafe(method_family = none)]
29        pub unsafe fn setName(&self, name: &NSString);
30
31        #[unsafe(method(delegate))]
32        #[unsafe(method_family = none)]
33        pub unsafe fn delegate(&self) -> Option<Retained<ProtocolObject<dyn NSCacheDelegate>>>;
34
35        /// Setter for [`delegate`][Self::delegate].
36        #[unsafe(method(setDelegate:))]
37        #[unsafe(method_family = none)]
38        pub unsafe fn setDelegate(&self, delegate: Option<&ProtocolObject<dyn NSCacheDelegate>>);
39
40        #[unsafe(method(objectForKey:))]
41        #[unsafe(method_family = none)]
42        pub unsafe fn objectForKey(&self, key: &KeyType) -> Option<Retained<ObjectType>>;
43
44        #[unsafe(method(setObject:forKey:))]
45        #[unsafe(method_family = none)]
46        pub unsafe fn setObject_forKey(&self, obj: &ObjectType, key: &KeyType);
47
48        #[unsafe(method(setObject:forKey:cost:))]
49        #[unsafe(method_family = none)]
50        pub unsafe fn setObject_forKey_cost(&self, obj: &ObjectType, key: &KeyType, g: NSUInteger);
51
52        #[unsafe(method(removeObjectForKey:))]
53        #[unsafe(method_family = none)]
54        pub unsafe fn removeObjectForKey(&self, key: &KeyType);
55
56        #[unsafe(method(removeAllObjects))]
57        #[unsafe(method_family = none)]
58        pub unsafe fn removeAllObjects(&self);
59
60        #[unsafe(method(totalCostLimit))]
61        #[unsafe(method_family = none)]
62        pub unsafe fn totalCostLimit(&self) -> NSUInteger;
63
64        /// Setter for [`totalCostLimit`][Self::totalCostLimit].
65        #[unsafe(method(setTotalCostLimit:))]
66        #[unsafe(method_family = none)]
67        pub unsafe fn setTotalCostLimit(&self, total_cost_limit: NSUInteger);
68
69        #[unsafe(method(countLimit))]
70        #[unsafe(method_family = none)]
71        pub unsafe fn countLimit(&self) -> NSUInteger;
72
73        /// Setter for [`countLimit`][Self::countLimit].
74        #[unsafe(method(setCountLimit:))]
75        #[unsafe(method_family = none)]
76        pub unsafe fn setCountLimit(&self, count_limit: NSUInteger);
77
78        #[unsafe(method(evictsObjectsWithDiscardedContent))]
79        #[unsafe(method_family = none)]
80        pub unsafe fn evictsObjectsWithDiscardedContent(&self) -> bool;
81
82        /// Setter for [`evictsObjectsWithDiscardedContent`][Self::evictsObjectsWithDiscardedContent].
83        #[unsafe(method(setEvictsObjectsWithDiscardedContent:))]
84        #[unsafe(method_family = none)]
85        pub unsafe fn setEvictsObjectsWithDiscardedContent(
86            &self,
87            evicts_objects_with_discarded_content: bool,
88        );
89    );
90}
91
92/// Methods declared on superclass `NSObject`.
93impl<KeyType: Message, ObjectType: Message> NSCache<KeyType, ObjectType> {
94    extern_methods!(
95        #[unsafe(method(init))]
96        #[unsafe(method_family = init)]
97        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
98
99        #[unsafe(method(new))]
100        #[unsafe(method_family = new)]
101        pub unsafe fn new() -> Retained<Self>;
102    );
103}
104
105extern_protocol!(
106    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nscachedelegate?language=objc)
107    pub unsafe trait NSCacheDelegate: NSObjectProtocol {
108        #[optional]
109        #[unsafe(method(cache:willEvictObject:))]
110        #[unsafe(method_family = none)]
111        unsafe fn cache_willEvictObject(&self, cache: &NSCache, obj: &AnyObject);
112    }
113);