[][src]Struct parse_dat_url::DatUrl

pub struct DatUrl<'a> { /* fields omitted */ }

Main structure exported. It holds a reference to the string itself, but it is capable of becoming owned, in order to send it across threads.

It accepts valid urls as well, such as HTTP, domains or IP based URLs. Mal-formed url data might fail, such as bad formatted IPv6 addresses. It is capable to clone the structure into a onwed reference, as it uses Cow internally.

Example

use parse_dat_url::DatUrl;

if let Ok(dat_url) = DatUrl::parse("dat://584faa05d394190ab1a3f0240607f9bf2b7e2bd9968830a11cf77db0cea36a21+0.0.0.1/path/to+file.txt") {
  println!("{}", dat_url);
}

Methods

impl<'a> DatUrl<'a>[src]

pub fn parse(url: &str) -> Result<DatUrl, Error>[src]

Main parsing operation. Returns a struct which makes reference to the &str passed, with the same lifetime.

It is capable to clone the structure into a onwed reference, as it uses Cow internally.

pub fn into_owned(self) -> DatUrl<'static>[src]

Converts a DatUrl with a 'a lifetime into a owned struct, with the 'static lifetime.

Examples

use parse_dat_url::{DatUrl, Error};
// A dynamic URL example.
let url = String::from("dat://584faa05d394190ab1a3f0240607f9bf2b7e2bd9968830a11cf77db0cea36a21+0.0.0.1/path/to+file.txt");
let dat_url = DatUrl::parse(&url)?;
let owned_dat_url : DatUrl<'static> = dat_url.into_owned();

pub fn scheme(&self) -> &Cow<str>[src]

Returns a reference to the scheme used on the url. If no scheme is provided on the string, it fallsback to dat://

pub fn host(&self) -> &Cow<str>[src]

Returns the host part of the url.

pub fn version(&self) -> &Option<Cow<str>>[src]

Returns a reference to the version on the dat url, if present.

pub fn path(&self) -> &Option<Cow<str>>[src]

Returns a reference to the path on the dat url, if present.

Trait Implementations

impl<'a> From<DatUrl<'a>> for Url[src]

impl<'a> AsRef<Url> for DatUrl<'a>[src]

impl<'a> Clone for DatUrl<'a>[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl<'a> PartialEq<DatUrl<'a>> for DatUrl<'a>[src]

impl<'a> Eq for DatUrl<'a>[src]

impl<'a> Display for DatUrl<'a>[src]

impl<'a> Debug for DatUrl<'a>[src]

impl<'a> TryFrom<&'a str> for DatUrl<'a>[src]

type Error = Error

The type returned in the event of a conversion error.

impl<'a> FromStr for DatUrl<'a>[src]

type Err = Error

The associated error which can be returned from parsing.

impl<'a> Serialize for DatUrl<'a>[src]

impl<'de: 'a, 'a> Deserialize<'de> for DatUrl<'a>[src]

Auto Trait Implementations

impl<'a> Sync for DatUrl<'a>

impl<'a> Send for DatUrl<'a>

impl<'a> Unpin for DatUrl<'a>

impl<'a> UnwindSafe for DatUrl<'a>

impl<'a> RefUnwindSafe for DatUrl<'a>

Blanket Implementations

impl<T> From<T> for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: Deserialize<'de>, 
[src]