objc2_social/generated/
SLRequest.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#[cfg(feature = "objc2-accounts")]
7use objc2_accounts::*;
8use objc2_foundation::*;
9
10use crate::*;
11
12/// [Apple's documentation](https://developer.apple.com/documentation/social/slrequestmethod?language=objc)
13// NS_ENUM
14#[repr(transparent)]
15#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
16pub struct SLRequestMethod(pub NSInteger);
17impl SLRequestMethod {
18    #[doc(alias = "SLRequestMethodGET")]
19    pub const GET: Self = Self(0);
20    #[doc(alias = "SLRequestMethodPOST")]
21    pub const POST: Self = Self(1);
22    #[doc(alias = "SLRequestMethodDELETE")]
23    pub const DELETE: Self = Self(2);
24    #[doc(alias = "SLRequestMethodPUT")]
25    pub const PUT: Self = Self(3);
26}
27
28unsafe impl Encode for SLRequestMethod {
29    const ENCODING: Encoding = NSInteger::ENCODING;
30}
31
32unsafe impl RefEncode for SLRequestMethod {
33    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
34}
35
36/// [Apple's documentation](https://developer.apple.com/documentation/social/slrequesthandler?language=objc)
37#[cfg(feature = "block2")]
38pub type SLRequestHandler =
39    *mut block2::DynBlock<dyn Fn(*mut NSData, *mut NSHTTPURLResponse, *mut NSError)>;
40
41extern_class!(
42    /// [Apple's documentation](https://developer.apple.com/documentation/social/slrequest?language=objc)
43    #[unsafe(super(NSObject))]
44    #[derive(Debug, PartialEq, Eq, Hash)]
45    pub struct SLRequest;
46);
47
48extern_conformance!(
49    unsafe impl NSObjectProtocol for SLRequest {}
50);
51
52impl SLRequest {
53    extern_methods!(
54        /// # Safety
55        ///
56        /// - `service_type` might not allow `None`.
57        /// - `url` might not allow `None`.
58        /// - `parameters` generic should be of the correct type.
59        /// - `parameters` might not allow `None`.
60        #[unsafe(method(requestForServiceType:requestMethod:URL:parameters:))]
61        #[unsafe(method_family = none)]
62        pub unsafe fn requestForServiceType_requestMethod_URL_parameters(
63            service_type: Option<&NSString>,
64            request_method: SLRequestMethod,
65            url: Option<&NSURL>,
66            parameters: Option<&NSDictionary>,
67        ) -> Option<Retained<SLRequest>>;
68
69        #[cfg(feature = "objc2-accounts")]
70        #[unsafe(method(account))]
71        #[unsafe(method_family = none)]
72        pub unsafe fn account(&self) -> Option<Retained<ACAccount>>;
73
74        #[cfg(feature = "objc2-accounts")]
75        /// Setter for [`account`][Self::account].
76        ///
77        /// # Safety
78        ///
79        /// `account` might not allow `None`.
80        #[unsafe(method(setAccount:))]
81        #[unsafe(method_family = none)]
82        pub unsafe fn setAccount(&self, account: Option<&ACAccount>);
83
84        #[unsafe(method(requestMethod))]
85        #[unsafe(method_family = none)]
86        pub unsafe fn requestMethod(&self) -> SLRequestMethod;
87
88        #[unsafe(method(URL))]
89        #[unsafe(method_family = none)]
90        pub unsafe fn URL(&self) -> Option<Retained<NSURL>>;
91
92        #[unsafe(method(parameters))]
93        #[unsafe(method_family = none)]
94        pub unsafe fn parameters(&self) -> Option<Retained<NSDictionary>>;
95
96        /// # Safety
97        ///
98        /// - `data` might not allow `None`.
99        /// - `name` might not allow `None`.
100        /// - `type` might not allow `None`.
101        /// - `filename` might not allow `None`.
102        #[unsafe(method(addMultipartData:withName:type:filename:))]
103        #[unsafe(method_family = none)]
104        pub unsafe fn addMultipartData_withName_type_filename(
105            &self,
106            data: Option<&NSData>,
107            name: Option<&NSString>,
108            r#type: Option<&NSString>,
109            filename: Option<&NSString>,
110        );
111
112        /// # Safety
113        ///
114        /// - `data` might not allow `None`.
115        /// - `name` might not allow `None`.
116        /// - `type` might not allow `None`.
117        #[deprecated]
118        #[unsafe(method(addMultipartData:withName:type:))]
119        #[unsafe(method_family = none)]
120        pub unsafe fn addMultipartData_withName_type(
121            &self,
122            data: Option<&NSData>,
123            name: Option<&NSString>,
124            r#type: Option<&NSString>,
125        );
126
127        #[unsafe(method(preparedURLRequest))]
128        #[unsafe(method_family = none)]
129        pub unsafe fn preparedURLRequest(&self) -> Option<Retained<NSURLRequest>>;
130
131        #[cfg(feature = "block2")]
132        /// # Safety
133        ///
134        /// `handler` must be a valid pointer.
135        #[unsafe(method(performRequestWithHandler:))]
136        #[unsafe(method_family = none)]
137        pub unsafe fn performRequestWithHandler(&self, handler: SLRequestHandler);
138    );
139}
140
141/// Methods declared on superclass `NSObject`.
142impl SLRequest {
143    extern_methods!(
144        #[unsafe(method(init))]
145        #[unsafe(method_family = init)]
146        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
147
148        #[unsafe(method(new))]
149        #[unsafe(method_family = new)]
150        pub unsafe fn new() -> Retained<Self>;
151    );
152}