Struct ApiRouteBuilder

Source
pub struct ApiRouteBuilder<'a> { /* private fields */ }

Trait Implementations§

Source§

impl<'a> RouteBuilder<'a> for ApiRouteBuilder<'a>

Source§

fn build(self) -> Result<Uri, Error>

Tries to build a URI from path arguments and parameters.

use crate::uri_routes::{RouteBuilder, ApiRouteBuilder};
let route = ApiRouteBuilder::new("google.com").build().unwrap();
assert_eq!(route, "https://google.com")
Source§

fn with_param<T: ToString>(self, name: String, value: T) -> Self

Add a parameter key/pair to the builder.

use crate::uri_routes::{RouteBuilder, ApiRouteBuilder};
let route = ApiRouteBuilder::new("fqdm.org")
    .with_param("page".into(), 1)
    .build()
    .unwrap();
assert_eq!(route, "https://fqdm.org?page=1")
Source§

fn with_path(self, path: String) -> Self

Add a path argument to the end of the path buffer.

use crate::uri_routes::{RouteBuilder, ApiRouteBuilder};
let route = ApiRouteBuilder::new("fqdm.org")
    .with_path("resource".into())
    .build()
    .unwrap();
assert_eq!(route, "https://fqdm.org/resource")
Source§

fn with_path_weight(self, path: String, weight: f32) -> Self

Inserts a path argument with the desired weight.

use crate::uri_routes::{RouteBuilder, ApiRouteBuilder};
let route = ApiRouteBuilder::new("fqdm.org")
    .with_path_weight("resource0".into(), 2.0)
    .with_path_weight("resource1".into(), 1.0)
    .build()
    .unwrap();
assert_eq!(route, "https://fqdm.org/resource1/resource0")
Source§

fn with_scheme(self, scheme: String) -> Self

Tries to build a URI from path arguments and parameters.

use crate::uri_routes::{RouteBuilder, ApiRouteBuilder};
let route = ApiRouteBuilder::new("localhost")
    .with_scheme("file".into())
    .build()
    .unwrap();
assert_eq!(route, "file://localhost")
Source§

fn new(host: &'a str) -> Self

New instance of a RouteBuilder.

Auto Trait Implementations§

§

impl<'a> Freeze for ApiRouteBuilder<'a>

§

impl<'a> RefUnwindSafe for ApiRouteBuilder<'a>

§

impl<'a> Send for ApiRouteBuilder<'a>

§

impl<'a> Sync for ApiRouteBuilder<'a>

§

impl<'a> Unpin for ApiRouteBuilder<'a>

§

impl<'a> UnwindSafe for ApiRouteBuilder<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.