cataclysm 0.5.5

A simple http framework
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use super::{SessionParser};
use crate::Error;
use serde::{Serialize, de::{DeserializeOwned}};

/// Json implementation of a [SessionParser].
pub struct JsonSessionParser;

impl <T: Serialize + DeserializeOwned> SessionParser<T> for JsonSessionParser {
    fn from_str(source: String) -> Result<T, Error> {
        Ok(serde_json::from_str(&source)?)
    }

    fn to_string(source: T) -> Result<String, Error> {
        Ok(serde_json::to_string(&source)?)
    }
}