fn parse_helper(input: &str) -> Result<(Url, RepoUrl), ParseError> {
    let url = Url::parse(input)?;

    let scheme = url.scheme();
    if scheme != "fuchsia-pkg" {
        return Err(ParseError::InvalidScheme);
    }

    if url.port().is_some() {
        return Err(ParseError::CannotContainPort);
    }

    if !url.username().is_empty() {
        return Err(ParseError::CannotContainUsername);
    }

    if url.password().is_some() {
        return Err(ParseError::CannotContainPassword);
    }

    let host = if let Some(host) = url.host() {
        host.to_string()
    } else {
        return Err(ParseError::MissingHost);
    };
    if host.is_empty() {
        return Err(ParseError::EmptyHost);
    }

    Ok((url, RepoUrl { host }))
}
// Validates the fuchsia-pkg URL invariants that are common between PkgUrl and
// RepoUrl.
Validates the fuchsia-pkg URL invariants that are common between PkgUrl and
RepoUrl.
Validates the fuchsia - pkg URL invariants that are common between PkgUrl and RepoUrl .
fn parse_helper(input: &str) -> Result<(Url, RepoUrl), ParseError> {
    let url = Url::parse(input)?;
    let scheme = url.scheme();
    if scheme != "fuchsia-pkg" {
        return Err(ParseError::InvalidScheme);
    }
    if url.port().is_some() {
        return Err(ParseError::CannotContainPort);
    }
    if !url.username().is_empty() {
        return Err(ParseError::CannotContainUsername);
    }
    if url.password().is_some() {
        return Err(ParseError::CannotContainPassword);
    }
    let host = if let Some(host) = url.host() {
        host.to_string()
    } else {
        return Err(ParseError::MissingHost);
    };
    if host.is_empty() {
        return Err(ParseError::EmptyHost);
    }
    Ok((url, RepoUrl { host }))
}
fn parse_helper ( input : & str ) -> Result < ( Url , RepoUrl ) , ParseError > { let url = Url :: parse ( input ) ? ; let scheme = url . scheme ( ) ; if scheme != " " { return Err ( ParseError :: InvalidScheme ) ; } if url . port ( ) . is_some ( ) { return Err ( ParseError :: CannotContainPort ) ; } if ! url . username ( ) . is_empty ( ) { return Err ( ParseError :: CannotContainUsername ) ; } if url . password ( ) . is_some ( ) { return Err ( ParseError :: CannotContainPassword ) ; } let host = if let Some ( host ) = url . host ( ) { host . to_string ( ) } else { return Err ( ParseError :: MissingHost ) ; } ; if host . is_empty ( ) { return Err ( ParseError :: EmptyHost ) ; } Ok ( ( url , RepoUrl { host } ) ) }
Validates the fuchsia-pkg URL invariants that are common between PkgUrl and
RepoUrl.
Validates the fuchsia - pkg URL invariants that are common between PkgUrl and RepoUrl .
input
&str
input
&str