1use crate::object::r#ref::MaybeRef;
2use crate::object::{Object, ObjectLike};
3use crate::reader::{Readable, Reader, ReaderContext};
4use std::fmt::Debug;
5
6impl<'a, T, U> Readable<'a> for (T, U)
12where
13 T: ObjectLike<'a>,
14 U: ObjectLike<'a>,
15{
16 fn read(r: &mut Reader<'a>, ctx: &ReaderContext<'a>) -> Option<Self> {
17 r.skip_white_spaces_and_comments();
18 let t = r.read::<MaybeRef<T>>(ctx)?.resolve(ctx)?;
19 r.skip_white_spaces_and_comments();
20 let u = r.read::<MaybeRef<U>>(ctx)?.resolve(ctx)?;
21 Some((t, u))
22 }
23}
24
25impl<'a, T, U> TryFrom<Object<'a>> for (T, U)
26where
27 T: ObjectLike<'a>,
28 U: ObjectLike<'a>,
29{
30 type Error = ();
31
32 fn try_from(_: Object<'a>) -> Result<Self, Self::Error> {
33 Err(())
34 }
35}
36
37impl<'a, T, U> ObjectLike<'a> for (T, U)
38where
39 T: ObjectLike<'a> + Debug + Clone,
40 U: ObjectLike<'a> + Debug + Clone,
41{
42}
43
44impl<'a, T, U, V> Readable<'a> for (T, U, V)
45where
46 T: ObjectLike<'a>,
47 U: ObjectLike<'a>,
48 V: ObjectLike<'a>,
49{
50 fn read(r: &mut Reader<'a>, ctx: &ReaderContext<'a>) -> Option<Self> {
51 r.skip_white_spaces_and_comments();
52 let t = r.read::<MaybeRef<T>>(ctx)?.resolve(ctx)?;
53 r.skip_white_spaces_and_comments();
54 let u = r.read::<MaybeRef<U>>(ctx)?.resolve(ctx)?;
55 r.skip_white_spaces_and_comments();
56 let v = r.read::<MaybeRef<V>>(ctx)?.resolve(ctx)?;
57
58 Some((t, u, v))
59 }
60}
61
62impl<'a, T, U, V> TryFrom<Object<'a>> for (T, U, V)
63where
64 T: ObjectLike<'a>,
65 U: ObjectLike<'a>,
66 V: ObjectLike<'a>,
67{
68 type Error = ();
69
70 fn try_from(_: Object<'a>) -> Result<Self, Self::Error> {
71 Err(())
72 }
73}
74
75impl<'a, T, U, V> ObjectLike<'a> for (T, U, V)
76where
77 T: ObjectLike<'a> + Debug + Clone,
78 U: ObjectLike<'a> + Debug + Clone,
79 V: ObjectLike<'a> + Debug + Clone,
80{
81}
82
83impl<'a, T, U, V, W> Readable<'a> for (T, U, V, W)
84where
85 T: ObjectLike<'a>,
86 U: ObjectLike<'a>,
87 V: ObjectLike<'a>,
88 W: ObjectLike<'a>,
89{
90 fn read(r: &mut Reader<'a>, ctx: &ReaderContext<'a>) -> Option<Self> {
91 r.skip_white_spaces_and_comments();
92 let t = r.read::<MaybeRef<T>>(ctx)?.resolve(ctx)?;
93 r.skip_white_spaces_and_comments();
94 let u = r.read::<MaybeRef<U>>(ctx)?.resolve(ctx)?;
95 r.skip_white_spaces_and_comments();
96 let v = r.read::<MaybeRef<V>>(ctx)?.resolve(ctx)?;
97 r.skip_white_spaces_and_comments();
98 let w = r.read::<MaybeRef<W>>(ctx)?.resolve(ctx)?;
99
100 Some((t, u, v, w))
101 }
102}
103
104impl<'a, T, U, V, W> TryFrom<Object<'a>> for (T, U, V, W)
105where
106 T: ObjectLike<'a>,
107 U: ObjectLike<'a>,
108 V: ObjectLike<'a>,
109 W: ObjectLike<'a>,
110{
111 type Error = ();
112
113 fn try_from(_: Object<'a>) -> Result<Self, Self::Error> {
114 Err(())
115 }
116}
117
118impl<'a, T, U, V, W> ObjectLike<'a> for (T, U, V, W)
119where
120 T: ObjectLike<'a> + Debug + Clone,
121 U: ObjectLike<'a> + Debug + Clone,
122 V: ObjectLike<'a> + Debug + Clone,
123 W: ObjectLike<'a> + Debug + Clone,
124{
125}
126
127impl<'a, T, U, V, W, X> Readable<'a> for (T, U, V, W, X)
128where
129 T: ObjectLike<'a>,
130 U: ObjectLike<'a>,
131 V: ObjectLike<'a>,
132 W: ObjectLike<'a>,
133 X: ObjectLike<'a>,
134{
135 fn read(r: &mut Reader<'a>, ctx: &ReaderContext<'a>) -> Option<Self> {
136 r.skip_white_spaces_and_comments();
137 let t = r.read::<MaybeRef<T>>(ctx)?.resolve(ctx)?;
138 r.skip_white_spaces_and_comments();
139 let u = r.read::<MaybeRef<U>>(ctx)?.resolve(ctx)?;
140 r.skip_white_spaces_and_comments();
141 let v = r.read::<MaybeRef<V>>(ctx)?.resolve(ctx)?;
142 r.skip_white_spaces_and_comments();
143 let w = r.read::<MaybeRef<W>>(ctx)?.resolve(ctx)?;
144 r.skip_white_spaces_and_comments();
145 let x = r.read::<MaybeRef<X>>(ctx)?.resolve(ctx)?;
146
147 Some((t, u, v, w, x))
148 }
149}
150
151impl<'a, T, U, V, W, X> TryFrom<Object<'a>> for (T, U, V, W, X)
152where
153 T: ObjectLike<'a>,
154 U: ObjectLike<'a>,
155 V: ObjectLike<'a>,
156 W: ObjectLike<'a>,
157 X: ObjectLike<'a>,
158{
159 type Error = ();
160
161 fn try_from(_: Object<'a>) -> Result<Self, Self::Error> {
162 Err(())
163 }
164}
165
166impl<'a, T, U, V, W, X> ObjectLike<'a> for (T, U, V, W, X)
167where
168 T: ObjectLike<'a> + Debug + Clone,
169 U: ObjectLike<'a> + Debug + Clone,
170 V: ObjectLike<'a> + Debug + Clone,
171 W: ObjectLike<'a> + Debug + Clone,
172 X: ObjectLike<'a> + Debug + Clone,
173{
174}