Struct http::Version

Overview

HTTP version

This module contains a definition of the Version type. The Version type is intended to be accessed through the root of the crate (http::Version) rather than this module.

The Version type contains constants that represent the various versions of the HTTP protocol.

Examples

use http::Version;

let http11 = Version::HTTP_11;
let http2 = Version::HTTP_2;
assert!(http11 != http2);

println!("{:?}", http2);

Trait Implementations

impl PartialEq for Version
fn eq(value: any, value1: any) -> bool

Compare two values for equality.

Examples

assert_eq!(1.eq(2), false);
assert_eq!(2.eq(2), true);
assert_eq!(2.eq(1), false);
fn ne(value: any, value1: any) -> bool

Compare two values for inequality.

Examples

assert_eq!(1.ne(2), true);
assert_eq!(2.ne(2), false);
assert_eq!(2.ne(1), true);
impl Eq for Version
impl PartialOrd for Version
fn partial_cmp(value: any, value1: any) -> Option

Compare two values.

Examples

use std::cmp::Ordering;

assert_eq!(1.partial_cmp(2), Some(Ordering::Less));
assert_eq!(2.partial_cmp(2), Some(Ordering::Equal));
assert_eq!(2.partial_cmp(1), Some(Ordering::Greater));
fn lt(value: any, value1: any) -> bool

Tests less than (for self and other) and is used by the < operator.

Examples

assert_eq!(1.0 < 1.0, false);
assert_eq!(1.0 < 2.0, true);
assert_eq!(2.0 < 1.0, false);
fn le(value: any, value1: any) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator.

Examples

assert_eq!(1.0 <= 1.0, true);
assert_eq!(1.0 <= 2.0, true);
assert_eq!(2.0 <= 1.0, false);
fn gt(value: any, value1: any) -> bool

Tests greater than (for self and other) and is used by the > operator.

Examples

assert_eq!(1.0 > 1.0, false);
assert_eq!(1.0 > 2.0, false);
assert_eq!(2.0 > 1.0, true);
fn ge(value: any, value1: any) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator.

Examples

assert_eq!(1.0 >= 1.0, true);
assert_eq!(1.0 >= 2.0, false);
assert_eq!(2.0 >= 1.0, true);
impl Ord for Version
fn cmp(value: any, value1: any) -> Ordering

Compare two values.

Examples

use std::cmp::Ordering;

assert_eq!(1.cmp(2), Ordering::Less);
assert_eq!(2.cmp(2), Ordering::Equal);
assert_eq!(2.cmp(1), Ordering::Greater);
fn min(value: any, value1: any) -> Ordering

Return the minimum of two values.

Examples

assert_eq!(1.min(2), 1);
assert_eq!(2.min(2), 2);
assert_eq!(2.min(1), 1);
fn max(value: any, value1: any) -> Ordering

Return the maximum of two values.

Examples

assert_eq!(1.max(2), 2);
assert_eq!(2.max(2), 2);
assert_eq!(2.max(1), 2);

Protocols

protocol PARTIAL_EQ
if value == b { }

Test two versions for partial equality.

Examples

use std::ops::partial_eq;

use http::Version;

let http11 = Version::HTTP_11;
let http2 = Version::HTTP_2;

assert_eq!(partial_eq(http11, http11), true);
assert_eq!(partial_eq(http11, http2), false);
assert_eq!(partial_eq(http2, http11), false);
protocol EQ
if value == b { }

Test two versions for total equality.

Examples

use std::ops::eq;

use http::Version;

let http11 = Version::HTTP_11;
let http2 = Version::HTTP_2;

assert_eq!(eq(http11, http11), true);
assert_eq!(eq(http11, http2), false);
assert_eq!(eq(http2, http11), false);
protocol PARTIAL_CMP
if value < b { }

Perform a partial ordered comparison between two versions.

Examples

use http::Version;

let http11 = Version::HTTP_11;
let http2 = Version::HTTP_2;

assert!(http11 < http2);
assert!(http2 > http11);
assert!(http11 == http11);

Using explicit functions:

use std::cmp::Ordering;
use std::ops::partial_cmp;

use http::Version;

let http11 = Version::HTTP_11;
let http2 = Version::HTTP_2;

assert_eq!(partial_cmp(http11, http2), Some(Ordering::Less));
assert_eq!(partial_cmp(http2, http11), Some(Ordering::Greater));
assert_eq!(partial_cmp(http11, http11), Some(Ordering::Equal));
protocol CMP
if value < b { }

Perform a totally ordered comparison between two versions.

Examples

use std::cmp::Ordering;
use std::ops::cmp;

use http::Version;

let http11 = Version::HTTP_11;
let http2 = Version::HTTP_2;

assert_eq!(cmp(http11, http2), Ordering::Less);
assert_eq!(cmp(http2, http11), Ordering::Greater);
assert_eq!(cmp(http11, http11), Ordering::Equal);
protocol HASH
let $out = hash(value)

Hash the version.

Examples

use std::ops::hash;

use http::Version;

let http2 = Version::HTTP_2;

assert_eq!(hash(http2), hash(http2));
protocol DEBUG_FMT
format!("{:?}", value)

Debug print the Version.

Examples

use http::Version;

let http11 = Version::HTTP_11;
let http2 = Version::HTTP_2;

println!("{:?}", http2);
protocol LT
if $a < $b { }

The protocol behind the < operator.

protocol LE
if $a <= $b { }

The protocol behind the <= operator.

protocol GT
if $a > $b { }

The protocol behind the > operator.

protocol GE
if $a >= $b { }

The protocol behind the >= operator.

protocol MIN
$a.min($b)

The implementation protocol for the PartialOrd::min method.

protocol MAX
$a.max($b)

The implementation protocol for the PartialOrd::max method.