winget_types/url/
license_url.rs1use core::{fmt, str::FromStr};
2
3use url::ParseError;
4
5use super::DecodedUrl;
6
7#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Ord, Hash)]
8#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
9#[cfg_attr(feature = "serde", serde(transparent))]
10pub struct LicenseUrl(DecodedUrl);
11
12impl LicenseUrl {
13 #[inline]
15 pub fn as_str(&self) -> &str {
16 self.0.as_str()
17 }
18}
19
20impl AsRef<str> for LicenseUrl {
21 fn as_ref(&self) -> &str {
22 self.0.as_ref()
23 }
24}
25
26impl fmt::Display for LicenseUrl {
27 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
28 self.0.fmt(f)
29 }
30}
31
32impl FromStr for LicenseUrl {
33 type Err = ParseError;
34
35 #[inline]
36 fn from_str(src: &str) -> Result<Self, Self::Err> {
37 DecodedUrl::from_str(src).map(Self)
38 }
39}