pub struct DatUrl<'a> { /* private fields */ }
Expand description
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);
}
Implementations§
Source§impl<'a> DatUrl<'a>
impl<'a> DatUrl<'a>
Sourcepub fn parse(url: &str) -> Result<DatUrl<'_>, Error>
pub fn parse(url: &str) -> Result<DatUrl<'_>, Error>
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.
Sourcepub fn into_owned(self) -> DatUrl<'static>
pub fn into_owned(self) -> DatUrl<'static>
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();
Sourcepub fn scheme(&self) -> &Cow<'_, str>
pub fn scheme(&self) -> &Cow<'_, str>
Returns a reference to the scheme used on the url. If no scheme is provided on the string, it fallsback to dat://
Trait Implementations§
Source§impl<'de: 'a, 'a> Deserialize<'de> for DatUrl<'a>
impl<'de: 'a, 'a> Deserialize<'de> for DatUrl<'a>
Source§fn deserialize<D>(deserializer: D) -> Result<DatUrl<'a>, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<DatUrl<'a>, D::Error>where
D: Deserializer<'de>,
impl<'a> Eq for DatUrl<'a>
impl<'a> StructuralPartialEq for DatUrl<'a>
Auto Trait Implementations§
impl<'a> Freeze for DatUrl<'a>
impl<'a> RefUnwindSafe for DatUrl<'a>
impl<'a> Send for DatUrl<'a>
impl<'a> Sync for DatUrl<'a>
impl<'a> Unpin for DatUrl<'a>
impl<'a> UnwindSafe for DatUrl<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)