1use http::header::HeaderMap;
2
3pub enum Frame<D> {
4 Data(D),
5 Trailers(HeaderMap),
6}
7
8impl<D> Frame<D> {
9 #[inline]
10 pub fn into_data(self) -> Result<D, Self> {
11 match self {
12 Self::Data(data) => Ok(data),
13 this => Err(this),
14 }
15 }
16
17 #[inline]
18 pub fn into_trailers(self) -> Result<HeaderMap, Self> {
19 match self {
20 Self::Trailers(trailers) => Ok(trailers),
21 this => Err(this),
22 }
23 }
24
25 #[inline]
26 pub fn data_ref(&self) -> Option<&D> {
27 match self {
28 Self::Data(data) => Some(data),
29 _ => None,
30 }
31 }
32
33 #[inline]
34 pub fn data_ref_mut(&mut self) -> Option<&mut D> {
35 match self {
36 Self::Data(data) => Some(data),
37 _ => None,
38 }
39 }
40}