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
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 #[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 #[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 #[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 #[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 #[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
92impl<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 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);