1use axum::response::{IntoResponse, IntoResponseParts};
2
3pub(crate) enum Either<L, R> {
4 Left(L),
5 Right(R),
6}
7
8impl<L, R> IntoResponseParts for Either<L, R>
9where
10 L: IntoResponseParts,
11 R: IntoResponseParts,
12{
13 type Error = Either<L::Error, R::Error>;
14
15 fn into_response_parts(
16 self,
17 res: axum::response::ResponseParts,
18 ) -> Result<axum::response::ResponseParts, Self::Error> {
19 match self {
20 Either::Left(l) => l.into_response_parts(res).map_err(|e| Either::Left(e)),
21 Either::Right(r) => r.into_response_parts(res).map_err(|e| Either::Right(e)),
22 }
23 }
24}
25
26impl<L, R> IntoResponse for Either<L, R>
27where
28 L: IntoResponse,
29 R: IntoResponse,
30{
31 fn into_response(self) -> axum::response::Response {
32 match self {
33 Either::Left(l) => l.into_response(),
34 Either::Right(r) => r.into_response(),
35 }
36 }
37}