use crate::core::AppState;
use crate::core::pingora::handle_route::renderer::Renderer;

pub struct PingoraAdapter<T: 'static = ()> {
    pub state: &'static AppState<T>,
    pub renderer: Renderer,
}

impl<T: 'static> PingoraAdapter<T>
where
    T: Send + Sync + 'static,
{
    pub(crate) fn from_state(
        state: &'static AppState<T>,
    ) -> Self {

        Self {
            state,
            renderer: Renderer::default(),
        }
    }

    pub(crate) fn from_state_and_renderer(
        state: &'static AppState<T>,
        renderer: Renderer,
    ) -> Self {

        Self {
            state,
            renderer,
        }
    }
}

impl<T> PingoraAdapter<T> 
where
    T: Send + Sync + 'static,
{
    pub fn renderer(mut self, renderer: Renderer) -> Self {
        self.renderer = renderer;
        self
    }
}
