pub struct RepositoryUrl { /* private fields */ }Expand description
Like CanonicalUrl, but attempts to represent an underlying source repository, abstracting
away details like the specific commit or branch, or the subdirectory to build within the
repository.
For example, https://github.com/pypa/package.git#subdirectory=pkg_a and
https://github.com/pypa/package.git#subdirectory=pkg_b would map to different
CanonicalUrl values, but the same RepositoryUrl, since they map to the same
resource.
The additional information it holds should only be used to discriminate between sources that hold the exact same commit in their canonical representation, but may differ in the contents such as when Git LFS is enabled.
A different cache key will be computed when Git LFS is enabled.
When Git LFS is false or None, the cache key remains unchanged.
Implementations§
Methods from Deref<Target = SafeUrl>§
Sourcepub fn as_url(&self) -> &SafeUrl
pub fn as_url(&self) -> &SafeUrl
Borrow the URL with the default Unserializable policy.
Return the authority, including any credentials and port.
Sourcepub fn cannot_be_a_base(&self) -> bool
pub fn cannot_be_a_base(&self) -> bool
Return whether the URL has an opaque path instead of path segments.
Sourcepub fn port_or_known_default(&self) -> Option<u16>
pub fn port_or_known_default(&self) -> Option<u16>
Return the explicit port or the scheme’s known default.
Sourcepub fn path_segments(&self) -> Option<Split<'_, char>>
pub fn path_segments(&self) -> Option<Split<'_, char>>
Return the percent-encoded path segments, unless the path is opaque.
Sourcepub fn query_pairs(&self) -> Parse<'_> ⓘ
pub fn query_pairs(&self) -> Parse<'_> ⓘ
Return the decoded query name/value pairs.
Sourcepub fn fragment(&self) -> Option<&str>
pub fn fragment(&self) -> Option<&str>
Return the fragment, without the leading hash, if present.
Sourcepub fn to_file_path(&self) -> Result<PathBuf, ()>
pub fn to_file_path(&self) -> Result<PathBuf, ()>
Convert a file URL to a filesystem path.
Sourcepub fn join(&self, input: &str) -> Result<SafeUrl<P>, SafeUrlError>
pub fn join(&self, input: &str) -> Result<SafeUrl<P>, SafeUrlError>
Parse a string as an URL, with this URL as the base URL.
Sourcepub fn without_credentials(&self) -> Cow<'_, SafeUrl<P>>
pub fn without_credentials(&self) -> Cow<'_, SafeUrl<P>>
Return the URL with sensitive userinfo removed, retaining its serialization policy.
The complete query is retained; display and debug formatting redact recognized credentials.
Removing userinfo does not make an Unserializable URL serializable:
use uv_redacted::SafeUrl;
let url = SafeUrl::parse("https://user:password@example.com/file.whl")?;
serde_json::to_string(&url.without_credentials())?;Sourcepub fn displayable_with_credentials(&self) -> impl Display
pub fn displayable_with_credentials(&self) -> impl Display
Returns Display implementation that doesn’t mask credentials.
Sourcepub fn redact_in(&self, message: &str) -> String
pub fn redact_in(&self, message: &str) -> String
Redact all occurrences of this URL in a message.
This is useful for errors from external tools, which may include the credentialed URL in
their command or output instead of using the URL’s Display implementation.
Sourcepub fn serialize_internal<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
P: InternalSerializationPolicy,
S: Serializer,
pub fn serialize_internal<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
P: InternalSerializationPolicy,
S: Serializer,
Serialize the complete URL using the internal representation of the Url struct.
A field using this serializer must declare the Raw policy:
use uv_redacted::{SafeUrl, policy::Raw};
#[derive(serde::Serialize)]
struct CachedUrl {
#[serde(serialize_with = "SafeUrl::<Raw>::serialize_internal")]
url: SafeUrl,
}serialize_internal method calls require Raw as well:
use uv_redacted::SafeUrl;
let url = SafeUrl::parse("https://user:password@example.com")?;
url.serialize_internal(serde_json::value::Serializer)?;use uv_redacted::{SafeUrl, policy::Stripped};
let url = SafeUrl::parse("https://user:password@example.com")?
.with_policy(Stripped);
url.serialize_internal(serde_json::value::Serializer)?;