1use crate::raw::*;
42use crate::*;
43
44pub enum TwoWays<ONE, TWO> {
48 One(ONE),
50 Two(TWO),
52}
53
54impl<ONE: oio::Read, TWO: oio::Read> oio::Read for TwoWays<ONE, TWO> {
55 async fn read(&mut self) -> Result<Buffer> {
56 match self {
57 TwoWays::One(v) => v.read().await,
58 TwoWays::Two(v) => v.read().await,
59 }
60 }
61}
62
63impl<ONE: oio::Write, TWO: oio::Write> oio::Write for TwoWays<ONE, TWO> {
64 async fn write(&mut self, bs: Buffer) -> Result<()> {
65 match self {
66 Self::One(v) => v.write(bs).await,
67 Self::Two(v) => v.write(bs).await,
68 }
69 }
70
71 async fn close(&mut self) -> Result<Metadata> {
72 match self {
73 Self::One(v) => v.close().await,
74 Self::Two(v) => v.close().await,
75 }
76 }
77
78 async fn abort(&mut self) -> Result<()> {
79 match self {
80 Self::One(v) => v.abort().await,
81 Self::Two(v) => v.abort().await,
82 }
83 }
84}
85
86impl<ONE: oio::Copy, TWO: oio::Copy> oio::Copy for TwoWays<ONE, TWO> {
87 async fn next(&mut self) -> Result<Option<usize>> {
88 match self {
89 Self::One(v) => v.next().await,
90 Self::Two(v) => v.next().await,
91 }
92 }
93
94 async fn close(&mut self) -> Result<Metadata> {
95 match self {
96 Self::One(v) => v.close().await,
97 Self::Two(v) => v.close().await,
98 }
99 }
100
101 async fn abort(&mut self) -> Result<()> {
102 match self {
103 Self::One(v) => v.abort().await,
104 Self::Two(v) => v.abort().await,
105 }
106 }
107}
108
109impl<ONE: oio::List, TWO: oio::List> oio::List for TwoWays<ONE, TWO> {
110 async fn next(&mut self) -> Result<Option<oio::Entry>> {
111 match self {
112 Self::One(v) => v.next().await,
113 Self::Two(v) => v.next().await,
114 }
115 }
116}
117
118pub enum ThreeWays<ONE, TWO, THREE> {
122 One(ONE),
124 Two(TWO),
126 Three(THREE),
128}
129
130impl<ONE: oio::Read, TWO: oio::Read, THREE: oio::Read> oio::Read for ThreeWays<ONE, TWO, THREE> {
131 async fn read(&mut self) -> Result<Buffer> {
132 match self {
133 ThreeWays::One(v) => v.read().await,
134 ThreeWays::Two(v) => v.read().await,
135 ThreeWays::Three(v) => v.read().await,
136 }
137 }
138}
139
140impl<ONE: oio::Write, TWO: oio::Write, THREE: oio::Write> oio::Write
141 for ThreeWays<ONE, TWO, THREE>
142{
143 async fn write(&mut self, bs: Buffer) -> Result<()> {
144 match self {
145 Self::One(v) => v.write(bs).await,
146 Self::Two(v) => v.write(bs).await,
147 Self::Three(v) => v.write(bs).await,
148 }
149 }
150
151 async fn close(&mut self) -> Result<Metadata> {
152 match self {
153 Self::One(v) => v.close().await,
154 Self::Two(v) => v.close().await,
155 Self::Three(v) => v.close().await,
156 }
157 }
158
159 async fn abort(&mut self) -> Result<()> {
160 match self {
161 Self::One(v) => v.abort().await,
162 Self::Two(v) => v.abort().await,
163 Self::Three(v) => v.abort().await,
164 }
165 }
166}
167
168impl<ONE: oio::List, TWO: oio::List, THREE: oio::List> oio::List for ThreeWays<ONE, TWO, THREE> {
169 async fn next(&mut self) -> Result<Option<oio::Entry>> {
170 match self {
171 Self::One(v) => v.next().await,
172 Self::Two(v) => v.next().await,
173 Self::Three(v) => v.next().await,
174 }
175 }
176}
177
178pub enum FourWays<ONE, TWO, THREE, FOUR> {
182 One(ONE),
184 Two(TWO),
186 Three(THREE),
188 Four(FOUR),
190}
191
192impl<ONE, TWO, THREE, FOUR> oio::Read for FourWays<ONE, TWO, THREE, FOUR>
193where
194 ONE: oio::Read,
195 TWO: oio::Read,
196 THREE: oio::Read,
197 FOUR: oio::Read,
198{
199 async fn read(&mut self) -> Result<Buffer> {
200 match self {
201 FourWays::One(v) => v.read().await,
202 FourWays::Two(v) => v.read().await,
203 FourWays::Three(v) => v.read().await,
204 FourWays::Four(v) => v.read().await,
205 }
206 }
207}
208
209impl<ONE, TWO, THREE, FOUR> oio::List for FourWays<ONE, TWO, THREE, FOUR>
210where
211 ONE: oio::List,
212 TWO: oio::List,
213 THREE: oio::List,
214 FOUR: oio::List,
215{
216 async fn next(&mut self) -> Result<Option<oio::Entry>> {
217 match self {
218 Self::One(v) => v.next().await,
219 Self::Two(v) => v.next().await,
220 Self::Three(v) => v.next().await,
221 Self::Four(v) => v.next().await,
222 }
223 }
224}