Struct vimwiki::vendor::uriparse::uri::URIBuilder[]

pub struct URIBuilder<'uri> { /* fields omitted */ }
Expand description

A builder type for [URI].

You must use the URI::scheme and URI::path functions before building as URIs always have a scheme and path. Everything else is optional.

Implementations

Sets the authority part of the URI.

It is optional to specify a authority.

Examples

use std::convert::TryFrom;

use uriparse::{Authority, Path, Scheme, URIBuilder};

let mut builder = URIBuilder::new();
builder
    .scheme(Scheme::HTTP)
    .authority(Some(Authority::try_from("example.com").unwrap()))
    .path(Path::try_from("/my/path").unwrap());
let reference = builder.build().unwrap();
assert_eq!(reference.to_string(), "http://example.com/my/path");

Consumes the builder and tries to build a URI.

This function will error in one of three situations:

  • A scheme and path were not specified in the builder.
  • While all individual components were valid, their combination as a URI was invalid.

Examples

First error type (scheme and/or path were not specified):

use std::convert::TryFrom;

use uriparse::{Authority, Path, URIBuilder};

let result = URIBuilder::new()
    .with_authority(Some(Authority::try_from("example.com").unwrap()))
    .with_path(Path::try_from("/my/path").unwrap())
    .build();
assert!(result.is_err());

Second error type (URI with no authority cannot have path starting with "//"):

use std::convert::TryFrom;

use uriparse::{Scheme, Path, URIBuilder};

let result = URIBuilder::new()
    .with_scheme(Scheme::URN)
    .with_path(Path::try_from("//path").unwrap())
    .build();
assert!(result.is_err());

Sets the fragment part of the URI.

It is optional to specify a fragment.

Examples

use std::convert::TryFrom;

use uriparse::{Fragment, Path, Scheme, URIBuilder};

let mut builder = URIBuilder::new();
builder
    .scheme(Scheme::URN)
    .path(Path::try_from("path").unwrap())
    .fragment(Some(Fragment::try_from("fragment").unwrap()));
let uri = builder.build().unwrap();
assert_eq!(uri.to_string(), "urn:path#fragment");

Constructs a new builder with nothing set.

Sets the path part of the URI.

It is required to specify a path. Not doing so will result in an error during the URIBuilder::build function.

Examples

use std::convert::TryFrom;

use uriparse::{Path, Scheme, URIBuilder};

let mut builder = URIBuilder::new();
builder
    .scheme(Scheme::URN)
    .path(Path::try_from("path").unwrap());
let uri = builder.build().unwrap();
assert_eq!(uri.to_string(), "urn:path");

Sets the query part of the URI reference.

It is optional to specify a query.

Examples

use std::convert::TryFrom;

use uriparse::{Path, Query, Scheme, URIBuilder};

let mut builder = URIBuilder::new();
builder
    .scheme(Scheme::URN)
    .path(Path::try_from("path").unwrap())
    .query(Some(Query::try_from("query").unwrap()));
let uri = builder.build().unwrap();
assert_eq!(uri.to_string(), "urn:path?query");

Sets the scheme part of the URI reference.

It is required to specify a scheme. Not doing so will result in an error during the URIBuilder::build function.

Examples

use std::convert::TryFrom;

use uriparse::{Authority, Path, Scheme, URIBuilder};

let mut builder = URIBuilder::new();
builder
    .scheme(Scheme::HTTP)
    .authority(Some(Authority::try_from("example.com").unwrap()))
    .path(Path::try_from("/my/path").unwrap());
let uri = builder.build().unwrap();
assert_eq!(uri.to_string(), "http://example.com/my/path");

Sets the authority part of the URI.1

If the given authority is not a valid authority (i.e. the conversion fails), an error is stored internally and checked during the URIBuilder::build function. The error state will be rewritten for any following calls to this function.

It is optional to specify an authority.

Examples

use uriparse::URIBuilder;

let mut builder = URIBuilder::new();
builder
    .try_scheme("http")
    .unwrap()
    .try_authority(Some("example.com"))
    .unwrap()
    .try_path("/my/path")
    .unwrap();
let uri = builder.build().unwrap();
assert_eq!(uri.to_string(), "http://example.com/my/path");

Sets the fragment part of the URI.

If the given fragment is not a valid fragment (i.e. the conversion fails), an error is stored internally and checked during the URIBuilder::build function. The error state will be rewritten for any following calls to this function.

It is optional to specify a fragment.

Examples

use uriparse::URIBuilder;

let mut builder = URIBuilder::new();
builder
    .try_scheme("urn")
    .unwrap()
    .try_path("path")
    .unwrap()
    .try_fragment(Some("fragment"))
    .unwrap();
let uri = builder.build().unwrap();
assert_eq!(uri.to_string(), "urn:path#fragment");

Sets the path part of the URI.

If the given path is not a valid path (i.e. the conversion fails), an error is stored internally and checked during the URIBuilder::build function. The error state will be rewritten for any following calls to this function.

It is required to specify a path.

Examples

use uriparse::URIBuilder;

let mut builder = URIBuilder::new();
builder
    .try_scheme("urn")
    .unwrap()
    .try_path("path")
    .unwrap();
let uri = builder.build().unwrap();
assert_eq!(uri.to_string(), "urn:path");

Sets the query part of the URI.

If the given query is not a valid query (i.e. the conversion fails), an error is stored internally and checked during the URIBuilder::build function. The error state will be rewritten for any following calls to this function.

It is optional to specify a query.

Examples

use uriparse::URIBuilder;

let mut builder = URIBuilder::new();
builder
    .try_scheme("urn")
    .unwrap()
    .try_path("path")
    .unwrap()
    .try_query(Some("query"))
    .unwrap();
let uri = builder.build().unwrap();
assert_eq!(uri.to_string(), "urn:path?query");

Sets the scheme part of the URI.

If the given scheme is not a valid scheme (i.e. the conversion fails), an error is stored internally and checked during the URIBuilder::build function. The error state will be rewritten for any following calls to this function.

It is required to specify a scheme. Not doing so will result in an error during the URIBuilder::build function.

Examples

use std::convert::TryFrom;

use uriparse::{Path, Scheme, URIBuilder};

let mut builder = URIBuilder::new();
builder
    .try_scheme("urn")
    .unwrap()
    .try_path("path")
    .unwrap();
let uri = builder.build().unwrap();
assert_eq!(uri.to_string(), "urn:path");

Consumes the builder and sets the authority part of the URI.

It is optional to specify an authority.

Examples

use std::convert::TryFrom;

use uriparse::{Authority, Path, Scheme, URIBuilder};

let uri = URIBuilder::new()
    .with_scheme(Scheme::HTTP)
    .with_authority(Some(Authority::try_from("example.com").unwrap()))
    .with_path(Path::try_from("/").unwrap())
    .build()
    .unwrap();
assert_eq!(uri.to_string(), "http://example.com/")

Consumes the builder and sets the fragment part of the URI.

It is optional to specify a fragment.

Examples

use std::convert::TryFrom;

use uriparse::{Fragment, Path, Scheme, URIBuilder};

let uri = URIBuilder::new()
    .with_scheme(Scheme::URN)
    .with_path(Path::try_from("").unwrap())
    .with_fragment(Some(Fragment::try_from("fragment").unwrap()))
    .build()
    .unwrap();
assert_eq!(uri.to_string(), "urn:#fragment")

Consumes the builder and sets the path part of the URI.

It is required to specify a path. Not doing so will result in an error during the URIBuilder::build function.

Examples

use std::convert::TryFrom;

use uriparse::{Authority, Path, Scheme, URIBuilder};

let reference = URIBuilder::new()
    .with_scheme(Scheme::HTTP)
    .with_authority(Some(Authority::try_from("example.com").unwrap()))
    .with_path(Path::try_from("/").unwrap())
    .build()
    .unwrap();
assert_eq!(reference.to_string(), "http://example.com/")

Consumes the builder and sets the query part of the URI.

It is optional to specify a query.

Examples

use std::convert::TryFrom;

use uriparse::{Path, Query, Scheme, URIBuilder};

let uri = URIBuilder::new()
    .with_scheme(Scheme::URN)
    .with_path(Path::try_from("").unwrap())
    .with_query(Some(Query::try_from("query").unwrap()))
    .build()
    .unwrap();
assert_eq!(uri.to_string(), "urn:?query")

Consumes the builder and sets the scheme part of the URI.

It is required to specify a scheme. Not doing so will result in an error during the URIBuilder::build function.

Examples

use std::convert::TryFrom;

use uriparse::{Authority, Path, Scheme, URIBuilder};

let reference = URIBuilder::new()
    .with_scheme(Scheme::HTTP)
    .with_authority(Some(Authority::try_from("example.com").unwrap()))
    .with_path(Path::try_from("/").unwrap())
    .build()
    .unwrap();
assert_eq!(reference.to_string(), "http://example.com/")

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Converts self into T using Into<T>. Read more

Converts self into a target type. Read more

Causes self to use its Binary implementation when Debug-formatted.

Causes self to use its Display implementation when Debug-formatted. Read more

Causes self to use its LowerExp implementation when Debug-formatted. Read more

Causes self to use its LowerHex implementation when Debug-formatted. Read more

Causes self to use its Octal implementation when Debug-formatted.

Causes self to use its Pointer implementation when Debug-formatted. Read more

Causes self to use its UpperExp implementation when Debug-formatted. Read more

Causes self to use its UpperHex implementation when Debug-formatted. Read more

Performs the conversion.

Performs the conversion.

Pipes by value. This is generally the method you want to use. Read more

Borrows self and passes that borrow into the pipe function. Read more

Mutably borrows self and passes that borrow into the pipe function. Read more

Borrows self, then passes self.borrow() into the pipe function. Read more

Mutably borrows self, then passes self.borrow_mut() into the pipe function. Read more

Borrows self, then passes self.as_ref() into the pipe function.

Mutably borrows self, then passes self.as_mut() into the pipe function. Read more

Borrows self, then passes self.deref() into the pipe function.

Mutably borrows self, then passes self.deref_mut() into the pipe function. Read more

Pipes a value into a function that cannot ordinarily be called in suffix position. Read more

Pipes a trait borrow into a function that cannot normally be called in suffix position. Read more

Pipes a trait mutable borrow into a function that cannot normally be called in suffix position. Read more

Pipes a trait borrow into a function that cannot normally be called in suffix position. Read more

Pipes a trait mutable borrow into a function that cannot normally be called in suffix position. Read more

Pipes a dereference into a function that cannot normally be called in suffix position. Read more

Pipes a mutable dereference into a function that cannot normally be called in suffix position. Read more

Pipes a reference into a function that cannot ordinarily be called in suffix position. Read more

Pipes a mutable reference into a function that cannot ordinarily be called in suffix position. Read more

Immutable access to a value. Read more

Mutable access to a value. Read more

Immutable access to the Borrow<B> of a value. Read more

Mutable access to the BorrowMut<B> of a value. Read more

Immutable access to the AsRef<R> view of a value. Read more

Mutable access to the AsMut<R> view of a value. Read more

Immutable access to the Deref::Target of a value. Read more

Mutable access to the Deref::Target of a value. Read more

Calls .tap() only in debug builds, and is erased in release builds.

Calls .tap_mut() only in debug builds, and is erased in release builds. Read more

Calls .tap_borrow() only in debug builds, and is erased in release builds. Read more

Calls .tap_borrow_mut() only in debug builds, and is erased in release builds. Read more

Calls .tap_ref() only in debug builds, and is erased in release builds. Read more

Calls .tap_ref_mut() only in debug builds, and is erased in release builds. Read more

Calls .tap_deref() only in debug builds, and is erased in release builds. Read more

Calls .tap_deref_mut() only in debug builds, and is erased in release builds. Read more

Provides immutable access for inspection. Read more

Calls tap in debug builds, and does nothing in release builds.

Provides mutable access for modification. Read more

Calls tap_mut in debug builds, and does nothing in release builds.

Provides immutable access to the reference for inspection.

Calls tap_ref in debug builds, and does nothing in release builds.

Provides mutable access to the reference for modification.

Calls tap_ref_mut in debug builds, and does nothing in release builds.

Provides immutable access to the borrow for inspection. Read more

Calls tap_borrow in debug builds, and does nothing in release builds.

Provides mutable access to the borrow for modification.

Calls tap_borrow_mut in debug builds, and does nothing in release builds. Read more

Immutably dereferences self for inspection.

Calls tap_deref in debug builds, and does nothing in release builds.

Mutably dereferences self for modification.

Calls tap_deref_mut in debug builds, and does nothing in release builds. Read more

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

Attempts to convert self into T using TryInto<T>. Read more

Attempts to convert self into a target type. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.