objc2_foundation/generated/
NSJSONSerialization.rs1use core::ptr::NonNull;
4use objc2::__framework_prelude::*;
5
6use crate::*;
7
8#[repr(transparent)]
11#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
12pub struct NSJSONReadingOptions(pub NSUInteger);
13bitflags::bitflags! {
14 impl NSJSONReadingOptions: NSUInteger {
15 #[doc(alias = "NSJSONReadingMutableContainers")]
16 const MutableContainers = 1<<0;
17 #[doc(alias = "NSJSONReadingMutableLeaves")]
18 const MutableLeaves = 1<<1;
19 #[doc(alias = "NSJSONReadingFragmentsAllowed")]
20 const FragmentsAllowed = 1<<2;
21 #[doc(alias = "NSJSONReadingJSON5Allowed")]
22 const JSON5Allowed = 1<<3;
23 #[doc(alias = "NSJSONReadingTopLevelDictionaryAssumed")]
24 const TopLevelDictionaryAssumed = 1<<4;
25#[deprecated]
26 #[doc(alias = "NSJSONReadingAllowFragments")]
27 const AllowFragments = NSJSONReadingOptions::FragmentsAllowed.0;
28 }
29}
30
31unsafe impl Encode for NSJSONReadingOptions {
32 const ENCODING: Encoding = NSUInteger::ENCODING;
33}
34
35unsafe impl RefEncode for NSJSONReadingOptions {
36 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
37}
38
39#[repr(transparent)]
42#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
43pub struct NSJSONWritingOptions(pub NSUInteger);
44bitflags::bitflags! {
45 impl NSJSONWritingOptions: NSUInteger {
46 #[doc(alias = "NSJSONWritingPrettyPrinted")]
47 const PrettyPrinted = 1<<0;
48 #[doc(alias = "NSJSONWritingSortedKeys")]
49 const SortedKeys = 1<<1;
50 #[doc(alias = "NSJSONWritingFragmentsAllowed")]
51 const FragmentsAllowed = 1<<2;
52 #[doc(alias = "NSJSONWritingWithoutEscapingSlashes")]
53 const WithoutEscapingSlashes = 1<<3;
54 }
55}
56
57unsafe impl Encode for NSJSONWritingOptions {
58 const ENCODING: Encoding = NSUInteger::ENCODING;
59}
60
61unsafe impl RefEncode for NSJSONWritingOptions {
62 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
63}
64
65extern_class!(
66 #[unsafe(super(NSObject))]
68 #[derive(Debug, PartialEq, Eq, Hash)]
69 pub struct NSJSONSerialization;
70);
71
72unsafe impl NSObjectProtocol for NSJSONSerialization {}
73
74impl NSJSONSerialization {
75 extern_methods!(
76 #[unsafe(method(isValidJSONObject:))]
77 #[unsafe(method_family = none)]
78 pub unsafe fn isValidJSONObject(obj: &AnyObject) -> bool;
79
80 #[cfg(all(feature = "NSData", feature = "NSError"))]
81 #[unsafe(method(dataWithJSONObject:options:error:_))]
82 #[unsafe(method_family = none)]
83 pub unsafe fn dataWithJSONObject_options_error(
84 obj: &AnyObject,
85 opt: NSJSONWritingOptions,
86 ) -> Result<Retained<NSData>, Retained<NSError>>;
87
88 #[cfg(all(feature = "NSData", feature = "NSError"))]
89 #[unsafe(method(JSONObjectWithData:options:error:_))]
90 #[unsafe(method_family = none)]
91 pub unsafe fn JSONObjectWithData_options_error(
92 data: &NSData,
93 opt: NSJSONReadingOptions,
94 ) -> Result<Retained<AnyObject>, Retained<NSError>>;
95
96 #[cfg(all(feature = "NSError", feature = "NSStream"))]
97 #[unsafe(method(JSONObjectWithStream:options:error:_))]
98 #[unsafe(method_family = none)]
99 pub unsafe fn JSONObjectWithStream_options_error(
100 stream: &NSInputStream,
101 opt: NSJSONReadingOptions,
102 ) -> Result<Retained<AnyObject>, Retained<NSError>>;
103 );
104}
105
106impl NSJSONSerialization {
108 extern_methods!(
109 #[unsafe(method(init))]
110 #[unsafe(method_family = init)]
111 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
112
113 #[unsafe(method(new))]
114 #[unsafe(method_family = new)]
115 pub unsafe fn new() -> Retained<Self>;
116 );
117}