Add as_str to UrlScheme

This commit is contained in:
Rasmus Melchior Jacobsen 2023-01-30 12:27:10 +01:00
parent b0977f9703
commit b01ab52041

View File

@ -25,6 +25,18 @@ pub enum UrlScheme {
}
impl UrlScheme {
/// str representation of the scheme
///
/// The returned str is always lowercase
pub fn as_str(&self) -> &str {
match self {
UrlScheme::HTTP => "http",
UrlScheme::HTTPS => "https",
UrlScheme::MQTT => "mqtt",
UrlScheme::MQTTS => "mqtts",
}
}
/// Get the default port for scheme
pub const fn default_port(&self) -> u16 {
match self {