fhttp_core/execution/
response_store.rs

1use std::collections::HashMap;
2use crate::path_utils::CanonicalizedPathBuf;
3
4#[derive(Debug)]
5pub struct ResponseStore {
6    response_data: HashMap<CanonicalizedPathBuf, String>,
7}
8
9impl ResponseStore {
10    pub fn new() -> Self {
11        ResponseStore { response_data: HashMap::new(), }
12    }
13
14    pub fn store<V: Into<String>>(
15        &mut self,
16        path: CanonicalizedPathBuf,
17        value: V
18    ) {
19        self.response_data.insert(path, value.into());
20    }
21
22    /// # Panics
23    /// panics when key not found.
24    pub fn get(&self, path: &CanonicalizedPathBuf) -> String {
25        self.response_data[path].clone()
26    }
27}
28
29impl Default for ResponseStore {
30    fn default() -> Self {
31        Self::new()
32    }
33}