pub struct Version {
pub major: usize,
pub minor: usize,
}Expand description
The HTTP version of a request or a response
Fields§
§major: usizeThe major revision number of the HTTP version
minor: usizeThe minor revision number of the HTTP version
Implementations§
Source§impl Version
impl Version
Sourcepub fn new<S>(version: S) -> Option<Self>
pub fn new<S>(version: S) -> Option<Self>
Initialize a Version by passing a &str or String to it in the format HTTP/{major}.{minor}. The corresponding numbers major and minor represent a HTTP version and are stored in the struct’s fields.
If for whatever reason this function fails to parse the &str provided into a Version, it will return None.
If the &str provided is parsed successfully, then the function will return a Some value containing a Version struct
§Example
fn main() {
let version = Version::new("HTTP/1.1").unwrap(); // Unwrap the `Some` value the `new` function returns
println!("{}", version); // Prints "HTTP/1.1" in the console
}Trait Implementations§
impl StructuralPartialEq for Version
Auto Trait Implementations§
impl Freeze for Version
impl RefUnwindSafe for Version
impl Send for Version
impl Sync for Version
impl Unpin for Version
impl UnwindSafe for Version
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