spacegate_kernel/extension/
reflect.rs

1use std::ops::{Deref, DerefMut};
2
3use hyper::http::Extensions;
4
5/// Reflect is a wrapper around `hyper::http::Extensions`
6///
7/// The extensions in reflect will be passed to the corresponded response if request is sent out from backend.
8#[derive(Clone, Default, Debug)]
9#[repr(transparent)]
10pub struct Reflect(Extensions);
11
12impl Deref for Reflect {
13    type Target = Extensions;
14
15    fn deref(&self) -> &Self::Target {
16        &self.0
17    }
18}
19
20impl DerefMut for Reflect {
21    fn deref_mut(&mut self) -> &mut Self::Target {
22        &mut self.0
23    }
24}
25
26impl Reflect {
27    pub fn new() -> Self {
28        Self(Extensions::new())
29    }
30    pub fn into_inner(self) -> Extensions {
31        self.0
32    }
33}
34
35impl From<Extensions> for Reflect {
36    fn from(ext: Extensions) -> Self {
37        Self(ext)
38    }
39}