pub struct RequestStartLine {
pub http_version: HttpVersion,
pub method: HttpMethod,
pub path: String,
pub url: Option<RequestPath>,
}Expand description
RequestStartLine is the first line of the HTTP request, which contains the method, path, and HTTP version.
Fields§
§http_version: HttpVersion§method: HttpMethod§path: String§url: Option<RequestPath>Implementations§
Source§impl RequestStartLine
impl RequestStartLine
Sourcepub fn new(
http_version: HttpVersion,
method: HttpMethod,
path: String,
) -> RequestStartLine
pub fn new( http_version: HttpVersion, method: HttpMethod, path: String, ) -> RequestStartLine
Sourcepub fn represent(&self) -> String
pub fn represent(&self) -> String
Converts the RequestStartLine object to a string.
§Returns
A string representation of the RequestStartLine.
Sourcepub fn parse<T>(line: T) -> Result<RequestStartLine, String>
pub fn parse<T>(line: T) -> Result<RequestStartLine, String>
Parses a string into a RequestStartLine object.
§Arguments
line- A string slice that contains the request line.
§Returns
Result<Self, String>- On success, a RequestStartLine object. On failure, an error message.
§Examples
use crate::start_line::RequestStartLine;
let request_line = "GET /index.html HTTP/1.1";
let start_line = RequestStartLine::parse(request_line).unwrap();
println!("{}", start_line);§Errors
Returns an error if:
- The request line is malformed.
- The number of parts is less than 3.
Sourcepub fn get_url(&mut self) -> RequestPath
pub fn get_url(&mut self) -> RequestPath
Sourcepub fn parse_url(&mut self) -> RequestPath
pub fn parse_url(&mut self) -> RequestPath
Sourcepub fn set_url(&mut self, url: RequestPath)
pub fn set_url(&mut self, url: RequestPath)
Trait Implementations§
Source§impl Clone for RequestStartLine
impl Clone for RequestStartLine
Source§fn clone(&self) -> RequestStartLine
fn clone(&self) -> RequestStartLine
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for RequestStartLine
impl Debug for RequestStartLine
Source§impl Default for RequestStartLine
impl Default for RequestStartLine
Source§fn default() -> RequestStartLine
fn default() -> RequestStartLine
Returns the “default value” for a type. Read more
Source§impl Display for RequestStartLine
impl Display for RequestStartLine
Source§impl From<RequestStartLine> for HttpStartLine
impl From<RequestStartLine> for HttpStartLine
Source§fn from(request: RequestStartLine) -> HttpStartLine
fn from(request: RequestStartLine) -> HttpStartLine
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for RequestStartLine
impl RefUnwindSafe for RequestStartLine
impl Send for RequestStartLine
impl Sync for RequestStartLine
impl Unpin for RequestStartLine
impl UnsafeUnpin for RequestStartLine
impl UnwindSafe for RequestStartLine
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> ParamValue for T
impl<T> ParamValue for T
Source§fn clone_box(&self) -> Box<dyn ParamValue>
fn clone_box(&self) -> Box<dyn ParamValue>
Clones this value and returns it as a boxed
ParamValue. Read moreSource§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Returns a reference to the underlying value as
Any. Read moreSource§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Returns a mutable reference to the underlying value as
Any. Read more