[][src]Struct milstian_internet_framework::application_layer::http::response::Message

pub struct Message {
    pub protocol: String,
    pub status: String,
    pub headers: HashMap<String, String, RandomState>,
    pub body: Vec<u8>,
}

Fields

protocol: Stringstatus: Stringheaders: HashMap<String, String, RandomState>body: Vec<u8>

Methods

impl Message[src]

pub fn new(
    protocol: String,
    status: String,
    headers: HashMap<String, String, RandomState>,
    body: Vec<u8>
) -> Message
[src]

pub fn header_to_string(&self) -> String[src]

Get the HTTP header as a new string

use milstian_http::response::Message;
use std::collections::HashMap;
assert_eq!(
    Message::new(
        "HTTP/1.0".to_string(),
        "200 OK".to_string(),
        HashMap::new(),
        b"<html><body>Nothing here</body></html>".to_vec()
    ).header_to_string(),
    "HTTP/1.0 200 OK\r\n\r\n".to_string()
);    

pub fn to_string(&mut self) -> String[src]

Convert response message into a string

use milstian_http::response::Message;
use std::collections::HashMap;
assert_eq!(
    Message::new(
        "HTTP/1.0".to_string(),
        "200 OK".to_string(),
        HashMap::new(),
        b"<html><body>Nothing here</body></html>".to_vec()
    ).to_string(),
    "HTTP/1.0 200 OK\r\n\r\n<html><body>Nothing here</body></html>".to_string()
);

pub fn to_bytes(&mut self) -> Vec<u8>[src]

Convert message into bytes

use milstian_http::response::Message;
use std::collections::HashMap;
assert_eq!(
    Message::new(
        "HTTP/1.0".to_string(),
        "200 OK".to_string(),
        HashMap::new(),
        b"<html><body>Nothing here</body></html>".to_vec()
    ).to_bytes(),
    b"HTTP/1.0 200 OK\r\n\r\n<html><body>Nothing here</body></html>".to_vec()
);

Auto Trait Implementations

impl Send for Message

impl Sync for Message

Blanket Implementations

impl<T> From for T[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Any for T where
    T: 'static + ?Sized
[src]