aboutsummaryrefslogtreecommitdiff
path: root/src/encoding/request.rs
blob: 124522c29cda91c127e5d706b76fe171c8d42341 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
use super::{headermap::HeaderMap, method::Method, uri::Uri};
use std::fmt::Display;

#[derive(Debug)]
pub struct Request {
    pub method: Method,
    pub uri: Uri,
    pub headers: HeaderMap,
}

impl Display for Request {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        let Self {
            headers,
            method,
            uri,
        } = self;
        write!(f, "{method} {uri} SIP/2.0\r\n")?;
        write!(f, "{headers}\r\n")?;
        Ok(())
    }
}