[−][src]Struct parse_dat_url::DatUrl
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(&self) -> 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.
fn try_from(s: &'a str) -> Result<Self, Self::Error>
[src]
impl<'a> FromStr for DatUrl<'a>
[src]
type Err = Error
The associated error which can be returned from parsing.
fn from_str(s: &str) -> Result<Self, Self::Err>
[src]
impl<'a> Serialize for DatUrl<'a>
[src]
impl<'de: 'a, 'a> Deserialize<'de> for DatUrl<'a>
[src]
fn deserialize<D>(deserializer: D) -> Result<DatUrl<'a>, D::Error> where
D: Deserializer<'de>,
[src]
D: Deserializer<'de>,
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]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> DeserializeOwned for T where
T: Deserialize<'de>,
[src]
T: Deserialize<'de>,