Struct Builder

struct Builder { ... }

A builder for Uris.

This type can be used to construct an instance of Uri through a builder pattern.

Implementations

impl Builder

fn new() -> Builder

Creates a new default instance of Builder to construct a Uri.

Examples

# use http::*;

let uri = uri::Builder::new()
    .scheme("https")
    .authority("hyper.rs")
    .path_and_query("/")
    .build()
    .unwrap();
fn scheme<T>(self: Self, scheme: T) -> Self
where
    T: TryInto<Scheme>,
    <T as TryInto<Scheme>>::Error: Into<Error>

Set the Scheme for this URI.

Examples

# use http::*;

let mut builder = uri::Builder::new();
builder.scheme("https");
fn authority<T>(self: Self, auth: T) -> Self
where
    T: TryInto<Authority>,
    <T as TryInto<Authority>>::Error: Into<Error>

Set the Authority for this URI.

Examples

# use http::*;

let uri = uri::Builder::new()
    .authority("tokio.rs")
    .build()
    .unwrap();
fn path_and_query<T>(self: Self, p_and_q: T) -> Self
where
    T: TryInto<PathAndQuery>,
    <T as TryInto<PathAndQuery>>::Error: Into<Error>

Set the PathAndQuery for this URI.

Examples

# use http::*;

let uri = uri::Builder::new()
    .path_and_query("/hello?foo=bar")
    .build()
    .unwrap();
fn build(self: Self) -> Result<Uri, Error>

Consumes this builder, and tries to construct a valid Uri from the configured pieces.

Errors

This function may return an error if any previously configured argument failed to parse or get converted to the internal representation. For example if an invalid scheme was specified via scheme("!@#%/^") the error will be returned when this function is called rather than when scheme was called.

Additionally, the various forms of URI require certain combinations of parts to be set to be valid. If the parts don't fit into any of the valid forms of URI, a new error is returned.

Examples

# use http::*;

let uri = Uri::builder()
    .build()
    .unwrap();

impl Debug for Builder

fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result

impl Default for Builder

fn default() -> Builder

impl Freeze for Builder

impl From for Builder

fn from(uri: Uri) -> Self

impl RefUnwindSafe for Builder

impl Send for Builder

impl Sync for Builder

impl Unpin for Builder

impl UnsafeUnpin for Builder

impl UnwindSafe for Builder

impl<T> Any for Builder

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for Builder

fn borrow(self: &Self) -> &T

impl<T> BorrowMut for Builder

fn borrow_mut(self: &mut Self) -> &mut T

impl<T> From for Builder

fn from(t: T) -> T

Returns the argument unchanged.

impl<T, U> Into for Builder

fn into(self: Self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom for Builder

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

impl<T, U> TryInto for Builder

fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>