1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
use objc2_foundation::*;
#[cfg(feature = "objc2-uniform-type-identifiers")]
use objc2_uniform_type_identifiers::*;
use crate::*;
extern_class!(
/// The HKAttachmentStore class provides an interface for accessing and storing HKAttachment objects.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/healthkit/hkattachmentstore?language=objc)
#[unsafe(super(NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct HKAttachmentStore;
);
extern_conformance!(
unsafe impl NSObjectProtocol for HKAttachmentStore {}
);
impl HKAttachmentStore {
extern_methods!(
#[cfg(feature = "HKHealthStore")]
/// The designated initializer to create an HKAttachmentStore.
///
/// Parameter `healthStore`: Specifies the HKHealthStore object to use.
#[unsafe(method(initWithHealthStore:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithHealthStore(
this: Allocated<Self>,
health_store: &HKHealthStore,
) -> Retained<Self>;
#[cfg(all(
feature = "HKAttachment",
feature = "HKObject",
feature = "block2",
feature = "objc2-uniform-type-identifiers"
))]
/// Creates a new HKAttachment using the passed in NSURL and attaches it to the specified HKObject.
///
/// Parameter `object`: The object for which to add the HKAttachment.
///
/// Parameter `name`: The name of the attachment.
///
/// Parameter `contentType`: The content type of the attachment.
///
/// Parameter `URL`: The NSURL to use to create the attachment.
///
/// Parameter `metadata`: Extra information describing the attachment.
///
/// Parameter `completion`: Called with an HKAttachment instance once the file was successfully saved and attached,
/// otherwise called with an error.
///
/// # Safety
///
/// `metadata` generic should be of the correct type.
#[unsafe(method(addAttachmentToObject:name:contentType:URL:metadata:completion:))]
#[unsafe(method_family = none)]
pub unsafe fn addAttachmentToObject_name_contentType_URL_metadata_completion(
&self,
object: &HKObject,
name: &NSString,
content_type: &UTType,
url: &NSURL,
metadata: Option<&NSDictionary<NSString, AnyObject>>,
completion: &block2::DynBlock<dyn Fn(*mut HKAttachment, *mut NSError)>,
);
#[cfg(all(feature = "HKAttachment", feature = "HKObject", feature = "block2"))]
/// Removes the given HKAttachment from the specified HKObject.
///
/// Parameter `attachment`: The HKAttachment to be removed.
///
/// Parameter `object`: The object from which to remove the attachment.
///
/// Parameter `completion`: Called once the remove operation finishes.
#[unsafe(method(removeAttachment:fromObject:completion:))]
#[unsafe(method_family = none)]
pub unsafe fn removeAttachment_fromObject_completion(
&self,
attachment: &HKAttachment,
object: &HKObject,
completion: &block2::DynBlock<dyn Fn(Bool, *mut NSError)>,
);
#[cfg(all(feature = "HKAttachment", feature = "HKObject", feature = "block2"))]
/// Retrieves a list of attachments for a given object.
///
/// Parameter `object`: The object for which to retrieve attachments.
///
/// Parameter `completion`: Called with a list of attachments or an error.
#[unsafe(method(getAttachmentsForObject:completion:))]
#[unsafe(method_family = none)]
pub unsafe fn getAttachmentsForObject_completion(
&self,
object: &HKObject,
completion: &block2::DynBlock<dyn Fn(*mut NSArray<HKAttachment>, *mut NSError)>,
);
#[cfg(all(feature = "HKAttachment", feature = "block2"))]
/// Retrieves the NSData for the given HKAttachment.
///
/// Prefer
/// `streamDataForAttachment:completion:`for large files that support incremental reading to limit your app's peak memory usage.
/// The attachment's data may not always be available locally, and could be stored in iCloud.
///
/// Parameter `attachment`: The attachment object to read data from.
///
/// Parameter `completion`: Called with an NSData or an error.
///
/// Returns: An NSProgress object to use for tracking the progress of downloading the attachment's data from iCloud.
#[unsafe(method(getDataForAttachment:completion:))]
#[unsafe(method_family = none)]
pub unsafe fn getDataForAttachment_completion(
&self,
attachment: &HKAttachment,
completion: &block2::DynBlock<dyn Fn(*mut NSData, *mut NSError)>,
) -> Retained<NSProgress>;
#[cfg(all(feature = "HKAttachment", feature = "block2"))]
/// Streams the given HKAttachment's data as ordered NSData chunks.
///
/// The dataHandler's done parameter is set to YES when all chunks have been streamed.
/// The attachment's data may not always be available locally, and could be stored in iCloud.
///
/// Parameter `attachment`: The attachment object to read data from.
///
/// Parameter `dataHandler`: Called with an NSData chunk or an error. When done is YES, the operation has completed.
///
/// Returns: An NSProgress object to use for tracking the progress of downloading the attachment's data from iCloud.
#[unsafe(method(streamDataForAttachment:dataHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn streamDataForAttachment_dataHandler(
&self,
attachment: &HKAttachment,
data_handler: &block2::DynBlock<dyn Fn(*mut NSData, *mut NSError, Bool)>,
) -> Retained<NSProgress>;
);
}
/// Methods declared on superclass `NSObject`.
impl HKAttachmentStore {
extern_methods!(
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub unsafe fn new() -> Retained<Self>;
);
}