objc2_foundation/generated/
NSCache.rs1use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6
7use crate::*;
8
9extern_class!(
10 #[unsafe(super(NSObject))]
12 #[derive(Debug, PartialEq, Eq, Hash)]
13 pub struct NSCache<KeyType: ?Sized = AnyObject, ObjectType: ?Sized = AnyObject>;
14);
15
16impl<KeyType: ?Sized + Message, ObjectType: ?Sized + Message> NSCache<KeyType, ObjectType> {
17 #[inline]
23 pub unsafe fn cast_unchecked<NewKeyType: ?Sized + Message, NewObjectType: ?Sized + Message>(
24 &self,
25 ) -> &NSCache<NewKeyType, NewObjectType> {
26 unsafe { &*((self as *const Self).cast()) }
27 }
28}
29
30extern_conformance!(
31 unsafe impl<KeyType: ?Sized, ObjectType: ?Sized> NSObjectProtocol for NSCache<KeyType, ObjectType> {}
32);
33
34impl<KeyType: Message, ObjectType: Message> NSCache<KeyType, ObjectType> {
35 extern_methods!(
36 #[cfg(feature = "NSString")]
37 #[unsafe(method(name))]
38 #[unsafe(method_family = none)]
39 pub unsafe fn name(&self) -> Retained<NSString>;
40
41 #[cfg(feature = "NSString")]
42 #[unsafe(method(setName:))]
46 #[unsafe(method_family = none)]
47 pub unsafe fn setName(&self, name: &NSString);
48
49 #[unsafe(method(delegate))]
53 #[unsafe(method_family = none)]
54 pub unsafe fn delegate(&self) -> Option<Retained<ProtocolObject<dyn NSCacheDelegate>>>;
55
56 #[unsafe(method(setDelegate:))]
62 #[unsafe(method_family = none)]
63 pub unsafe fn setDelegate(&self, delegate: Option<&ProtocolObject<dyn NSCacheDelegate>>);
64
65 #[unsafe(method(objectForKey:))]
66 #[unsafe(method_family = none)]
67 pub unsafe fn objectForKey(&self, key: &KeyType) -> Option<Retained<ObjectType>>;
68
69 #[unsafe(method(setObject:forKey:))]
70 #[unsafe(method_family = none)]
71 pub unsafe fn setObject_forKey(&self, obj: &ObjectType, key: &KeyType);
72
73 #[unsafe(method(setObject:forKey:cost:))]
74 #[unsafe(method_family = none)]
75 pub unsafe fn setObject_forKey_cost(&self, obj: &ObjectType, key: &KeyType, g: NSUInteger);
76
77 #[unsafe(method(removeObjectForKey:))]
78 #[unsafe(method_family = none)]
79 pub unsafe fn removeObjectForKey(&self, key: &KeyType);
80
81 #[unsafe(method(removeAllObjects))]
82 #[unsafe(method_family = none)]
83 pub unsafe fn removeAllObjects(&self);
84
85 #[unsafe(method(totalCostLimit))]
86 #[unsafe(method_family = none)]
87 pub unsafe fn totalCostLimit(&self) -> NSUInteger;
88
89 #[unsafe(method(setTotalCostLimit:))]
91 #[unsafe(method_family = none)]
92 pub unsafe fn setTotalCostLimit(&self, total_cost_limit: NSUInteger);
93
94 #[unsafe(method(countLimit))]
95 #[unsafe(method_family = none)]
96 pub unsafe fn countLimit(&self) -> NSUInteger;
97
98 #[unsafe(method(setCountLimit:))]
100 #[unsafe(method_family = none)]
101 pub unsafe fn setCountLimit(&self, count_limit: NSUInteger);
102
103 #[unsafe(method(evictsObjectsWithDiscardedContent))]
104 #[unsafe(method_family = none)]
105 pub unsafe fn evictsObjectsWithDiscardedContent(&self) -> bool;
106
107 #[unsafe(method(setEvictsObjectsWithDiscardedContent:))]
109 #[unsafe(method_family = none)]
110 pub unsafe fn setEvictsObjectsWithDiscardedContent(
111 &self,
112 evicts_objects_with_discarded_content: bool,
113 );
114 );
115}
116
117impl<KeyType: Message, ObjectType: Message> NSCache<KeyType, ObjectType> {
119 extern_methods!(
120 #[unsafe(method(init))]
121 #[unsafe(method_family = init)]
122 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
123
124 #[unsafe(method(new))]
125 #[unsafe(method_family = new)]
126 pub unsafe fn new() -> Retained<Self>;
127 );
128}
129
130extern_protocol!(
131 pub unsafe trait NSCacheDelegate: NSObjectProtocol {
133 #[optional]
138 #[unsafe(method(cache:willEvictObject:))]
139 #[unsafe(method_family = none)]
140 unsafe fn cache_willEvictObject(&self, cache: &NSCache, obj: &AnyObject);
141 }
142);