1use std::{fmt, str::FromStr};
9use thiserror::Error;
10
11#[derive(Debug, Clone, PartialEq, Eq)]
12pub struct Url(String);
13
14impl Url {
15 pub fn as_str(&self) -> &str {
17 &self.0
18 }
19 pub fn into_string(self) -> String {
21 self.0
22 }
23}
24
25#[derive(Debug, Error)]
26#[error("Unable to parset URL")]
27pub struct ParseError;
28
29impl FromStr for Url {
30 type Err = ParseError;
31 fn from_str(s: &str) -> Result<Self, Self::Err> {
32 Ok(Url(s.to_string()))
36 }
37}
38
39impl fmt::Display for Url {
40 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
41 write!(f, "{}", self.0)
42 }
43}
44
45impl From<Url> for String {
46 fn from(url: Url) -> Self {
47 url.0
48 }
49}