uv_pypi_types/
base_url.rs1use serde::{Deserialize, Serialize};
2use uv_redacted::DisplaySafeUrl;
3
4#[derive(Debug, Clone, Hash, Eq, PartialEq, Serialize, Deserialize)]
5pub struct BaseUrl(
6 #[serde(
7 serialize_with = "DisplaySafeUrl::serialize_internal",
8 deserialize_with = "DisplaySafeUrl::deserialize_internal"
9 )]
10 DisplaySafeUrl,
11);
12
13impl BaseUrl {
14 pub fn as_url(&self) -> &DisplaySafeUrl {
16 &self.0
17 }
18
19 pub fn as_str(&self) -> &str {
21 self.0.as_str()
22 }
23}
24
25impl From<DisplaySafeUrl> for BaseUrl {
26 fn from(url: DisplaySafeUrl) -> Self {
27 Self(url)
28 }
29}
30
31impl std::fmt::Display for BaseUrl {
32 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
33 self.0.fmt(f)
34 }
35}