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
16extern_conformance!(
17 unsafe impl<KeyType: ?Sized, ObjectType: ?Sized> NSObjectProtocol for NSCache<KeyType, ObjectType> {}
18);
19
20impl<KeyType: Message, ObjectType: Message> NSCache<KeyType, ObjectType> {
21 extern_methods!(
22 #[cfg(feature = "NSString")]
23 #[unsafe(method(name))]
24 #[unsafe(method_family = none)]
25 pub unsafe fn name(&self) -> Retained<NSString>;
26
27 #[cfg(feature = "NSString")]
28 #[unsafe(method(setName:))]
30 #[unsafe(method_family = none)]
31 pub unsafe fn setName(&self, name: &NSString);
32
33 #[unsafe(method(delegate))]
34 #[unsafe(method_family = none)]
35 pub unsafe fn delegate(&self) -> Option<Retained<ProtocolObject<dyn NSCacheDelegate>>>;
36
37 #[unsafe(method(setDelegate:))]
39 #[unsafe(method_family = none)]
40 pub unsafe fn setDelegate(&self, delegate: Option<&ProtocolObject<dyn NSCacheDelegate>>);
41
42 #[unsafe(method(objectForKey:))]
43 #[unsafe(method_family = none)]
44 pub unsafe fn objectForKey(&self, key: &KeyType) -> Option<Retained<ObjectType>>;
45
46 #[unsafe(method(setObject:forKey:))]
47 #[unsafe(method_family = none)]
48 pub unsafe fn setObject_forKey(&self, obj: &ObjectType, key: &KeyType);
49
50 #[unsafe(method(setObject:forKey:cost:))]
51 #[unsafe(method_family = none)]
52 pub unsafe fn setObject_forKey_cost(&self, obj: &ObjectType, key: &KeyType, g: NSUInteger);
53
54 #[unsafe(method(removeObjectForKey:))]
55 #[unsafe(method_family = none)]
56 pub unsafe fn removeObjectForKey(&self, key: &KeyType);
57
58 #[unsafe(method(removeAllObjects))]
59 #[unsafe(method_family = none)]
60 pub unsafe fn removeAllObjects(&self);
61
62 #[unsafe(method(totalCostLimit))]
63 #[unsafe(method_family = none)]
64 pub unsafe fn totalCostLimit(&self) -> NSUInteger;
65
66 #[unsafe(method(setTotalCostLimit:))]
68 #[unsafe(method_family = none)]
69 pub unsafe fn setTotalCostLimit(&self, total_cost_limit: NSUInteger);
70
71 #[unsafe(method(countLimit))]
72 #[unsafe(method_family = none)]
73 pub unsafe fn countLimit(&self) -> NSUInteger;
74
75 #[unsafe(method(setCountLimit:))]
77 #[unsafe(method_family = none)]
78 pub unsafe fn setCountLimit(&self, count_limit: NSUInteger);
79
80 #[unsafe(method(evictsObjectsWithDiscardedContent))]
81 #[unsafe(method_family = none)]
82 pub unsafe fn evictsObjectsWithDiscardedContent(&self) -> bool;
83
84 #[unsafe(method(setEvictsObjectsWithDiscardedContent:))]
86 #[unsafe(method_family = none)]
87 pub unsafe fn setEvictsObjectsWithDiscardedContent(
88 &self,
89 evicts_objects_with_discarded_content: bool,
90 );
91 );
92}
93
94impl<KeyType: Message, ObjectType: Message> NSCache<KeyType, ObjectType> {
96 extern_methods!(
97 #[unsafe(method(init))]
98 #[unsafe(method_family = init)]
99 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
100
101 #[unsafe(method(new))]
102 #[unsafe(method_family = new)]
103 pub unsafe fn new() -> Retained<Self>;
104 );
105}
106
107extern_protocol!(
108 pub unsafe trait NSCacheDelegate: NSObjectProtocol {
110 #[optional]
111 #[unsafe(method(cache:willEvictObject:))]
112 #[unsafe(method_family = none)]
113 unsafe fn cache_willEvictObject(&self, cache: &NSCache, obj: &AnyObject);
114 }
115);