kode-bridge 0.1.0

Cross-platform Rust library for sending HTTP requests over IPC channels (Unix sockets, planned Windows named pipes).
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use serde::{Deserialize, Serialize};
use serde_json::Value;
use std::convert::From;

use crate::errors::AnyError;

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Response {
    pub status: u16,
    pub headers: serde_json::Value,
    pub body: String,
}

impl Response {
    pub fn json(&self) -> Result<Value, AnyError> {
        serde_json::from_str(&self.body).map_err(AnyError::from)
    }
}