pub enum Scheme {
File,
Git,
Ssh,
Http,
Https,
Ext(String),
}
Expand description
A scheme or protocol for use in a Url
.
It defines how to talk to a given repository.
Variants§
File
A local resource that is accessible on the current host.
Git
A git daemon, like File
over TCP/IP.
Ssh
Launch git-upload-pack
through an ssh
tunnel.
Http
Use the HTTP protocol to talk to git servers.
Https
Use the HTTPS protocol to talk to git servers.
Ext(String)
Any other protocol or transport that isn’t known at compile time.
It’s used to support plug-in transports.
Implementations§
source§impl Scheme
impl Scheme
sourcepub fn as_str(&self) -> &str
pub fn as_str(&self) -> &str
Return ourselves parseable name.
Examples found in repository?
More examples
src/lib.rs (line 175)
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198
pub fn write_to(&self, mut out: impl std::io::Write) -> std::io::Result<()> {
if !(self.serialize_alternative_form && (self.scheme == Scheme::File || self.scheme == Scheme::Ssh)) {
out.write_all(self.scheme.as_str().as_bytes())?;
out.write_all(b"://")?;
}
match (&self.user, &self.host) {
(Some(user), Some(host)) => {
out.write_all(user.as_bytes())?;
out.write_all(&[b'@'])?;
out.write_all(host.as_bytes())?;
}
(None, Some(host)) => {
out.write_all(host.as_bytes())?;
}
(None, None) => {}
(Some(_user), None) => unreachable!("BUG: should not be possible to have a user but no host"),
};
if let Some(port) = &self.port {
write!(&mut out, ":{}", port)?;
}
if self.serialize_alternative_form && self.scheme == Scheme::Ssh {
out.write_all(b":")?;
}
out.write_all(&self.path)?;
Ok(())
}
Trait Implementations§
source§impl<'de> Deserialize<'de> for Scheme
impl<'de> Deserialize<'de> for Scheme
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl Ord for Scheme
impl Ord for Scheme
source§impl PartialEq<Scheme> for Scheme
impl PartialEq<Scheme> for Scheme
source§impl PartialOrd<Scheme> for Scheme
impl PartialOrd<Scheme> for Scheme
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read more