deboa 0.0.6

A friendly rest client on top of hyper.
Documentation
use crate::{request::DeboaRequest, Result};
use serde::{Deserialize, Serialize};

/// Trait that represents the request body.
pub trait RequestBody {
    /// Register the content type on the Deboa instance
    ///
    /// # Arguments
    ///
    /// * `request` - A mutable reference to the DeboaRequest instance
    ///
    fn register_content_type(&self, request: &mut DeboaRequest) -> ();
    /// Serialize the request body
    ///
    /// # Arguments
    ///
    /// * `value` - The request body to serialize
    ///
    /// # Returns
    ///
    /// * `Result<Vec<u8>>` - The serialized request body
    ///
    fn serialize<T: Serialize>(&self, value: T) -> Result<Vec<u8>>;
}

/// Trait that represents the response body.
pub trait ResponseBody {
    /// Deserialize the response body
    ///
    /// # Arguments
    ///
    /// * `value` - The response body to deserialize
    ///
    /// # Returns
    ///
    /// * `Result<T>` - The deserialized response body
    ///
    fn deserialize<T: for<'a> Deserialize<'a>>(&self, value: Vec<u8>) -> Result<T>;
}