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 #[doc(alias = "NSJSONReadingAllowFragments")]
26#[deprecated]
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
72extern_conformance!(
73 unsafe impl NSObjectProtocol for NSJSONSerialization {}
74);
75
76impl NSJSONSerialization {
77 extern_methods!(
78 #[unsafe(method(isValidJSONObject:))]
79 #[unsafe(method_family = none)]
80 pub unsafe fn isValidJSONObject(obj: &AnyObject) -> bool;
81
82 #[cfg(all(feature = "NSData", feature = "NSError"))]
83 #[unsafe(method(dataWithJSONObject:options:error:_))]
84 #[unsafe(method_family = none)]
85 pub unsafe fn dataWithJSONObject_options_error(
86 obj: &AnyObject,
87 opt: NSJSONWritingOptions,
88 ) -> Result<Retained<NSData>, Retained<NSError>>;
89
90 #[cfg(all(feature = "NSData", feature = "NSError"))]
91 #[unsafe(method(JSONObjectWithData:options:error:_))]
92 #[unsafe(method_family = none)]
93 pub unsafe fn JSONObjectWithData_options_error(
94 data: &NSData,
95 opt: NSJSONReadingOptions,
96 ) -> Result<Retained<AnyObject>, Retained<NSError>>;
97
98 #[cfg(all(feature = "NSError", feature = "NSStream"))]
99 #[unsafe(method(JSONObjectWithStream:options:error:_))]
100 #[unsafe(method_family = none)]
101 pub unsafe fn JSONObjectWithStream_options_error(
102 stream: &NSInputStream,
103 opt: NSJSONReadingOptions,
104 ) -> Result<Retained<AnyObject>, Retained<NSError>>;
105 );
106}
107
108impl NSJSONSerialization {
110 extern_methods!(
111 #[unsafe(method(init))]
112 #[unsafe(method_family = init)]
113 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
114
115 #[unsafe(method(new))]
116 #[unsafe(method_family = new)]
117 pub unsafe fn new() -> Retained<Self>;
118 );
119}